]> granicus.if.org Git - imagemagick/commitdiff
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=14434
authorCristy <mikayla-grace@urban-warrior.org>
Wed, 24 Apr 2019 22:13:31 +0000 (18:13 -0400)
committerCristy <mikayla-grace@urban-warrior.org>
Wed, 24 Apr 2019 22:13:31 +0000 (18:13 -0400)
coders/ps.c
coders/ps2.c
coders/ps3.c

index f5dcde5b1706af9b343b9f82f098d36628bc89e1..15a4bb6121677fa3c2eecd37fb7b3cf5451a5014 100644 (file)
@@ -128,16 +128,16 @@ static int MagickDLLCall PostscriptDelegateMessage(void *handle,
   offset=0;
   messages=(char **) handle;
   if (*messages == (char *) NULL)
-    *messages=(char *) AcquireQuantumMemory(length+1,sizeof(char *));
+    *messages=(char *) AcquireQuantumMemory((size_t) length+1,sizeof(char *));
   else
     {
-      offset=strlen(*messages);
-      *messages=(char *) ResizeQuantumMemory(*messages,offset+length+1,
+      offset=(ssize_t) strlen(*messages);
+      *messages=(char *) ResizeQuantumMemory(*messages,(size_t) offset+length+1,
         sizeof(char *));
     }
   if (*messages == (char *) NULL)
     return(0);
-  (void) memcpy(*messages+offset,message,length);
+  (void) memcpy(*messages+offset,message,(size_t) length);
   (*messages)[length+offset] ='\0';
   return(length);
 }
@@ -224,7 +224,7 @@ static MagickBooleanType InvokePostscriptDelegate(
 #endif
   if (ghost_info == (GhostInfo *) NULL)
     ExecuteGhostscriptCommand(command,status);
-  if ((ghost_info->revision)(&revision,sizeof(revision)) != 0)
+  if ((ghost_info->revision)(&revision,(int) sizeof(revision)) != 0)
     revision.revision=0;
   if (verbose != MagickFalse)
     {
@@ -713,9 +713,9 @@ static Image *ReadPSImage(const ImageInfo *image_info,ExceptionInfo *exception)
       if (i ==  (ssize_t) priority)
         continue;
     hires_bounds=bounds;
-    priority=(size_t) i;
+    priority=i;
   }
-  if ((fabs(hires_bounds.x2-hires_bounds.x1) >= MagickEpsilon) && 
+  if ((fabs(hires_bounds.x2-hires_bounds.x1) >= MagickEpsilon) &&
       (fabs(hires_bounds.y2-hires_bounds.y1) >= MagickEpsilon))
     {
       /*
@@ -1634,13 +1634,14 @@ static MagickBooleanType WritePSImage(const ImageInfo *image_info,Image *image,
       else
         if ((image->gravity != UndefinedGravity) &&
             (LocaleCompare(image_info->magick,"PS") == 0))
-          (void) CopyMagickString(page_geometry,PSPageGeometry,MagickPathExtent);
+          (void) CopyMagickString(page_geometry,PSPageGeometry,
+            MagickPathExtent);
     (void) ConcatenateMagickString(page_geometry,">",MagickPathExtent);
     (void) ParseMetaGeometry(page_geometry,&geometry.x,&geometry.y,
       &geometry.width,&geometry.height);
-    scale.x=(double) (geometry.width*delta.x)/resolution.x;
+    scale.x=PerceptibleReciprocal(resolution.x)*geometry.width*delta.x;
     geometry.width=(size_t) floor(scale.x+0.5);
-    scale.y=(double) (geometry.height*delta.y)/resolution.y;
+    scale.y=PerceptibleReciprocal(resolution.y)*geometry.height*delta.y;
     geometry.height=(size_t) floor(scale.y+0.5);
     (void) ParseAbsoluteGeometry(page_geometry,&media_info);
     (void) ParseGravityGeometry(image,page_geometry,&page_info,exception);
@@ -1914,7 +1915,7 @@ RestoreMSCWarning
       }
     (void) memset(&pixel,0,sizeof(pixel));
     pixel.alpha=(MagickRealType) TransparentAlpha;
-    index=0;
+    index=(Quantum) 0;
     x=0;
     if ((image_info->type != TrueColorType) &&
         (SetImageGray(image,exception) != MagickFalse))
index 206eb4fcb93b0f97072741dc77c30883a147b4c1..1ed77e348be51d70175c6949d2d2d0c6b3471e67 100644 (file)
@@ -533,13 +533,14 @@ static MagickBooleanType WritePS2Image(const ImageInfo *image_info,Image *image,
       else
         if ((image->gravity != UndefinedGravity) &&
             (LocaleCompare(image_info->magick,"PS") == 0))
-          (void) CopyMagickString(page_geometry,PSPageGeometry,MagickPathExtent);
+          (void) CopyMagickString(page_geometry,PSPageGeometry,
+            MagickPathExtent);
     (void) ConcatenateMagickString(page_geometry,">",MagickPathExtent);
     (void) ParseMetaGeometry(page_geometry,&geometry.x,&geometry.y,
       &geometry.width,&geometry.height);
-    scale.x=(double) (geometry.width*delta.x)/resolution.x;
+    scale.x=PerceptibleReciprocal(resolution.x)*geometry.width*delta.x;
     geometry.width=(size_t) floor(scale.x+0.5);
-    scale.y=(double) (geometry.height*delta.y)/resolution.y;
+    scale.y=PerceptibleReciprocal(resolution.y)*geometry.height*delta.y;
     geometry.height=(size_t) floor(scale.y+0.5);
     (void) ParseAbsoluteGeometry(page_geometry,&media_info);
     (void) ParseGravityGeometry(image,page_geometry,&page_info,exception);
index 6c5721d5257b8d0aae34acaedd8c6f87e6114d15..ab02db21b5fff16ca4d48fffaf41f601933bcd81 100644 (file)
@@ -963,8 +963,8 @@ static MagickBooleanType WritePS3Image(const ImageInfo *image_info,Image *image,
       }
     if (image->units == PixelsPerCentimeterResolution)
       {
-        resolution.x=(size_t) ((100.0*2.54*resolution.x+0.5)/100.0);
-        resolution.y=(size_t) ((100.0*2.54*resolution.y+0.5)/100.0);
+        resolution.x=(100.0*2.54*resolution.x+0.5)/100.0;
+        resolution.y=(100.0*2.54*resolution.y+0.5)/100.0;
       }
     SetGeometry(image,&geometry);
     (void) FormatLocaleString(page_geometry,MagickPathExtent,"%.20gx%.20g",
@@ -979,13 +979,14 @@ static MagickBooleanType WritePS3Image(const ImageInfo *image_info,Image *image,
       else
         if ((image->gravity != UndefinedGravity) &&
             (LocaleCompare(image_info->magick,"PS") == 0))
-          (void) CopyMagickString(page_geometry,PSPageGeometry,MagickPathExtent);
+          (void) CopyMagickString(page_geometry,PSPageGeometry,
+            MagickPathExtent);
     (void) ConcatenateMagickString(page_geometry,">",MagickPathExtent);
     (void) ParseMetaGeometry(page_geometry,&geometry.x,&geometry.y,
       &geometry.width,&geometry.height);
-    scale.x=(double) (geometry.width*delta.x)/resolution.x;
+    scale.x=PerceptibleReciprocal(resolution.x)*geometry.width*delta.x;
     geometry.width=(size_t) floor(scale.x+0.5);
-    scale.y=(double) (geometry.height*delta.y)/resolution.y;
+    scale.y=PerceptibleReciprocal(resolution.y)*geometry.height*delta.y;
     geometry.height=(size_t) floor(scale.y+0.5);
     (void) ParseAbsoluteGeometry(page_geometry,&media_info);
     (void) ParseGravityGeometry(image,page_geometry,&page_info,exception);