< prev index next >

src/java.desktop/share/native/liblcms/cmstypes.c

Print this page
rev 16232 : 8170798: Fix minor issues in java2d and sound coding.

@@ -2697,10 +2697,11 @@
     cmsStage *A = NULL, *B = NULL, *M = NULL;
     cmsStage * Matrix = NULL;
     cmsStage * CLUT = NULL;
     cmsUInt32Number offsetB = 0, offsetMat = 0, offsetM = 0, offsetC = 0, offsetA = 0;
     cmsUInt32Number BaseOffset, DirectoryPos, CurrentPos;
+    cmsInt32Number CurrentPos0;
 
     // Get the base for all offsets
     BaseOffset = io ->Tell(io) - sizeof(_cmsTagBase);
 
     if (Lut ->Elements != NULL)

@@ -2759,11 +2760,13 @@
 
         offsetB = io ->Tell(io) - BaseOffset;
         if (!WriteSetOfCurves(self, io, cmsSigParametricCurveType, B)) return FALSE;
     }
 
-    CurrentPos = io ->Tell(io);
+    CurrentPos0 = io ->Tell(io);
+    if (CurrentPos0 < 0) { return FALSE; }
+    CurrentPos = (cmsUInt32Number)CurrentPos0;
 
     if (!io ->Seek(io, DirectoryPos)) return FALSE;
 
     if (!_cmsWriteUInt32Number(io, offsetB)) return FALSE;
     if (!_cmsWriteUInt32Number(io, offsetMat)) return FALSE;

@@ -2882,11 +2885,11 @@
     cmsStage *A = NULL, *B = NULL, *M = NULL;
     cmsStage *Matrix = NULL;
     cmsStage *CLUT = NULL;
     cmsUInt32Number offsetB = 0, offsetMat = 0, offsetM = 0, offsetC = 0, offsetA = 0;
     cmsUInt32Number BaseOffset, DirectoryPos, CurrentPos;
-
+    cmsInt32Number CurrentPos0;
 
     BaseOffset = io ->Tell(io) - sizeof(_cmsTagBase);
 
     if (!cmsPipelineCheckAndRetreiveStages(Lut, 1, cmsSigCurveSetElemType, &B))
         if (!cmsPipelineCheckAndRetreiveStages(Lut, 3, cmsSigCurveSetElemType, cmsSigMatrixElemType, cmsSigCurveSetElemType, &B, &Matrix, &M))

@@ -2938,11 +2941,13 @@
 
         offsetB = io ->Tell(io) - BaseOffset;
         if (!WriteSetOfCurves(self, io, cmsSigParametricCurveType, B)) return FALSE;
     }
 
-    CurrentPos = io ->Tell(io);
+    CurrentPos0 = io ->Tell(io);
+    if (CurrentPos0 < 0) { return FALSE; }
+    CurrentPos = (cmsUInt32Number)CurrentPos0;
 
     if (!io ->Seek(io, DirectoryPos)) return FALSE;
 
     if (!_cmsWriteUInt32Number(io, offsetB)) return FALSE;
     if (!_cmsWriteUInt32Number(io, offsetMat)) return FALSE;

@@ -4480,10 +4485,11 @@
 // This one is a liitle bit more complex, so we don't use position tables this time.
 static
 cmsBool Type_MPE_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
 {
     cmsUInt32Number i, BaseOffset, DirectoryPos, CurrentPos;
+    cmsInt32Number CurrentPos0;
     int inputChan, outputChan;
     cmsUInt32Number ElemCount;
     cmsUInt32Number *ElementOffsets = NULL, *ElementSizes = NULL, Before;
     cmsStageSignature ElementSig;
     cmsPipeline* Lut = (cmsPipeline*) Ptr;

@@ -4545,11 +4551,13 @@
 
         Elem = Elem ->Next;
     }
 
     // Write the directory
-    CurrentPos = io ->Tell(io);
+    CurrentPos0 = io ->Tell(io);
+    if (CurrentPos0 < 0) { goto Error; }
+    CurrentPos = (cmsUInt32Number)CurrentPos0;
 
     if (!io ->Seek(io, DirectoryPos)) goto Error;
 
     for (i=0; i < ElemCount; i++) {
         if (!_cmsWriteUInt32Number(io, ElementOffsets[i])) goto Error;

@@ -5171,10 +5179,11 @@
     cmsHANDLE hDict = (cmsHANDLE) Ptr;
     const cmsDICTentry* p;
     cmsBool AnyName, AnyValue;
     cmsUInt32Number i, Count, Length;
     cmsUInt32Number DirectoryPos, CurrentPos, BaseOffset;
+    cmsInt32Number CurrentPos0;
    _cmsDICarray a;
 
     if (hDict == NULL) return FALSE;
 
     BaseOffset = io ->Tell(io) - sizeof(_cmsTagBase);

@@ -5221,11 +5230,14 @@
 
        p = cmsDictNextEntry(p);
     }
 
     // Write the directory
-    CurrentPos = io ->Tell(io);
+    CurrentPos0 = io ->Tell(io);
+    if (CurrentPos0 < 0) { goto Error; }
+    CurrentPos = (cmsUInt32Number)CurrentPos0;
+
     if (!io ->Seek(io, DirectoryPos)) goto Error;
 
     if (!WriteOffsetArray(io, &a, Count, Length)) goto Error;
 
     if (!io ->Seek(io, CurrentPos)) goto Error;
< prev index next >