@@ -211,7 +211,10 @@ static Image *ReadYUVImage(const ImageInfo *image_info,ExceptionInfo *exception)
211211 horizontal_factor ,(image -> rows + vertical_factor - 1 )/vertical_factor ,
212212 MagickTrue ,exception );
213213 if (chroma_image == (Image * ) NULL )
214- ThrowReaderException (ResourceLimitError ,"MemoryAllocationFailed" );
214+ {
215+ scanline = (unsigned char * ) RelinquishMagickMemory (scanline );
216+ ThrowReaderException (ResourceLimitError ,"MemoryAllocationFailed" );
217+ }
215218 /*
216219 Convert raster image to pixel packets.
217220 */
@@ -227,6 +230,7 @@ static Image *ReadYUVImage(const ImageInfo *image_info,ExceptionInfo *exception)
227230 status = OpenBlob (image_info ,image ,ReadBinaryBlobMode ,exception );
228231 if (status == MagickFalse )
229232 {
233+ scanline = (unsigned char * ) RelinquishMagickMemory (scanline );
230234 image = DestroyImageList (image );
231235 return ((Image * ) NULL );
232236 }
@@ -353,6 +357,7 @@ static Image *ReadYUVImage(const ImageInfo *image_info,ExceptionInfo *exception)
353357 status = OpenBlob (image_info ,image ,ReadBinaryBlobMode ,exception );
354358 if (status == MagickFalse )
355359 {
360+ scanline = (unsigned char * ) RelinquishMagickMemory (scanline );
356361 image = DestroyImageList (image );
357362 return ((Image * ) NULL );
358363 }
@@ -399,6 +404,7 @@ static Image *ReadYUVImage(const ImageInfo *image_info,ExceptionInfo *exception)
399404 status = OpenBlob (image_info ,image ,ReadBinaryBlobMode ,exception );
400405 if (status == MagickFalse )
401406 {
407+ scanline = (unsigned char * ) RelinquishMagickMemory (scanline );
402408 image = DestroyImageList (image );
403409 return ((Image * ) NULL );
404410 }
@@ -442,7 +448,10 @@ static Image *ReadYUVImage(const ImageInfo *image_info,ExceptionInfo *exception)
442448 TriangleFilter ,exception );
443449 chroma_image = DestroyImage (chroma_image );
444450 if (resize_image == (Image * ) NULL )
445- ThrowReaderException (ResourceLimitError ,"MemoryAllocationFailed" );
451+ {
452+ scanline = (unsigned char * ) RelinquishMagickMemory (scanline );
453+ ThrowReaderException (ResourceLimitError ,"MemoryAllocationFailed" );
454+ }
446455 for (y = 0 ; y < (ssize_t ) image -> rows ; y ++ )
447456 {
448457 q = GetAuthenticPixels (image ,0 ,y ,image -> columns ,1 ,exception );
@@ -491,6 +500,7 @@ static Image *ReadYUVImage(const ImageInfo *image_info,ExceptionInfo *exception)
491500 AcquireNextImage (image_info ,image ,exception );
492501 if (GetNextImageInList (image ) == (Image * ) NULL )
493502 {
503+ scanline = (unsigned char * ) RelinquishMagickMemory (scanline );
494504 image = DestroyImageList (image );
495505 return ((Image * ) NULL );
496506 }
0 commit comments