From a0ce171e29d6d324d9b60e09625761168692220d Mon Sep 17 00:00:00 2001 From: Cristy Date: Sun, 28 Aug 2022 17:32:20 -0400 Subject: [PATCH] repair memory issues for the unit tests --- coders/tiff.c | 2 +- magick/annotate.c | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/coders/tiff.c b/coders/tiff.c index 88e5f8fc9e..a0d3a70432 100644 --- a/coders/tiff.c +++ b/coders/tiff.c @@ -1798,7 +1798,7 @@ static Image *ReadTIFFImage(const ImageInfo *image_info, /* Convert stripped TIFF image. */ - extent=MagickMax(image->columns*(samples_per_pixel+extra_samples)* + extent=4*MagickMax(image->columns*(samples_per_pixel+extra_samples)* (image->depth+7)/8,TIFFStripSize(tiff)); strip_pixels=(unsigned char *) AcquireQuantumMemory(extent, sizeof(*strip_pixels)); diff --git a/magick/annotate.c b/magick/annotate.c index 23b861311a..3ba81f7b3b 100644 --- a/magick/annotate.c +++ b/magick/annotate.c @@ -1508,8 +1508,8 @@ static MagickBooleanType RenderFreetype(Image *image,const DrawInfo *draw_info, ft_status=FT_Open_Face(library,&args,face_index,&face); if (ft_status != 0) { - stream=RelinquishMagickMemory(stream); (void) FT_Done_FreeType(library); + stream=RelinquishMagickMemory(stream); ThrowFreetypeErrorException("UnableToReadFont",ft_status,args.pathname); args.pathname=DestroyString(args.pathname); return(MagickFalse); @@ -1565,6 +1565,7 @@ static MagickBooleanType RenderFreetype(Image *image,const DrawInfo *draw_info, { (void) FT_Done_Face(face); (void) FT_Done_FreeType(library); + stream=RelinquishMagickMemory(stream); ThrowFreetypeErrorException("UnrecognizedFontEncoding",ft_status, encoding); return(MagickFalse); @@ -1597,6 +1598,7 @@ static MagickBooleanType RenderFreetype(Image *image,const DrawInfo *draw_info, { (void) FT_Done_Face(face); (void) FT_Done_FreeType(library); + stream=RelinquishMagickMemory(stream); ThrowFreetypeErrorException("UnableToReadFont",ft_status, draw_info->font); return(MagickFalse); @@ -1636,6 +1638,7 @@ static MagickBooleanType RenderFreetype(Image *image,const DrawInfo *draw_info, { (void) FT_Done_Face(face); (void) FT_Done_FreeType(library); + stream=(FT_StreamRec *) RelinquishMagickMemory(stream); return(MagickTrue); } /* @@ -1954,6 +1957,7 @@ static MagickBooleanType RenderFreetype(Image *image,const DrawInfo *draw_info, annotate_info=DestroyDrawInfo(annotate_info); (void) FT_Done_Face(face); (void) FT_Done_FreeType(library); + stream=(FT_StreamRec *) RelinquishMagickMemory(stream); return(status); } #else