]> granicus.if.org Git - imagemagick/commitdiff
Fixed memory leaks reported in #1557.
authorDirk Lemstra <dirk@lemstra.org>
Sun, 28 Apr 2019 08:41:50 +0000 (10:41 +0200)
committerDirk Lemstra <dirk@lemstra.org>
Sun, 28 Apr 2019 08:41:50 +0000 (10:41 +0200)
coders/pdf.c
coders/ps3.c

index 1b9bf62832a79e50ae19f4bcabcc79b59f040a3e..249d2cff992e4ce674625618c716129bd35e3b35 100644 (file)
@@ -1184,19 +1184,19 @@ static MagickBooleanType Huffman2DEncodeImage(const ImageInfo *image_info,
   unsigned char
     *group4;
 
+  group4_image=CloneImage(inject_image,0,0,MagickTrue,exception);
+  if (group4_image == (Image *) NULL)
+    return(MagickFalse);
   status=MagickTrue;
   write_info=CloneImageInfo(image_info);
   (void) CopyMagickString(write_info->filename,"GROUP4:",MagickPathExtent);
   (void) CopyMagickString(write_info->magick,"GROUP4",MagickPathExtent);
-  group4_image=CloneImage(inject_image,0,0,MagickTrue,exception);
-  if (group4_image == (Image *) NULL)
-    return(MagickFalse);
   group4=(unsigned char *) ImageToBlob(write_info,group4_image,&length,
     exception);
   group4_image=DestroyImage(group4_image);
+  write_info=DestroyImageInfo(write_info);
   if (group4 == (unsigned char *) NULL)
     return(MagickFalse);
-  write_info=DestroyImageInfo(write_info);
   if (WriteBlob(image,length,group4) != (ssize_t) length)
     status=MagickFalse;
   group4=(unsigned char *) RelinquishMagickMemory(group4);
index ab02db21b5fff16ca4d48fffaf41f601933bcd81..7b9722fcdf1cdb5f189483c5068b09b3ff3695d9 100644 (file)
@@ -219,19 +219,19 @@ static MagickBooleanType Huffman2DEncodeImage(const ImageInfo *image_info,
   unsigned char
     *group4;
 
+  group4_image=CloneImage(inject_image,0,0,MagickTrue,exception);
+  if (group4_image == (Image *) NULL)
+    return(MagickFalse);
   status=MagickTrue;
   write_info=CloneImageInfo(image_info);
   (void) CopyMagickString(write_info->filename,"GROUP4:",MagickPathExtent);
   (void) CopyMagickString(write_info->magick,"GROUP4",MagickPathExtent);
-  group4_image=CloneImage(inject_image,0,0,MagickTrue,exception);
-  if (group4_image == (Image *) NULL)
-    return(MagickFalse);
   group4=(unsigned char *) ImageToBlob(write_info,group4_image,&length,
     exception);
   group4_image=DestroyImage(group4_image);
+  write_info=DestroyImageInfo(write_info);
   if (group4 == (unsigned char *) NULL)
     return(MagickFalse);
-  write_info=DestroyImageInfo(write_info);
   if (WriteBlob(image,length,group4) != (ssize_t) length)
     status=MagickFalse;
   group4=(unsigned char *) RelinquishMagickMemory(group4);