From 7b04c53c69792243d66d6876f843b850b3cc002b Mon Sep 17 00:00:00 2001 From: Dirk Lemstra Date: Sun, 28 Apr 2019 10:41:50 +0200 Subject: [PATCH] Fixed memory leaks reported in #1557. --- coders/pdf.c | 8 ++++---- coders/ps3.c | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/coders/pdf.c b/coders/pdf.c index 1b9bf6283..249d2cff9 100644 --- a/coders/pdf.c +++ b/coders/pdf.c @@ -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); diff --git a/coders/ps3.c b/coders/ps3.c index ab02db21b..7b9722fcd 100644 --- a/coders/ps3.c +++ b/coders/ps3.c @@ -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); -- 2.40.0