Skip to content
Permalink
Browse files Browse the repository at this point in the history
fix multiple memory leak in ReadYUVImage
  • Loading branch information
jgj212 authored and dlemstra committed Sep 14, 2017
1 parent c29d15c commit ef8f406
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions coders/yuv.c
Expand Up @@ -211,7 +211,10 @@ static Image *ReadYUVImage(const ImageInfo *image_info,ExceptionInfo *exception)
horizontal_factor,(image->rows+vertical_factor-1)/vertical_factor,
MagickTrue,exception);
if (chroma_image == (Image *) NULL)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
{
scanline=(unsigned char *) RelinquishMagickMemory(scanline);
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
}
/*
Convert raster image to pixel packets.
*/
Expand All @@ -227,6 +230,7 @@ static Image *ReadYUVImage(const ImageInfo *image_info,ExceptionInfo *exception)
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
{
scanline=(unsigned char *) RelinquishMagickMemory(scanline);
image=DestroyImageList(image);
return((Image *) NULL);
}
Expand Down Expand Up @@ -353,6 +357,7 @@ static Image *ReadYUVImage(const ImageInfo *image_info,ExceptionInfo *exception)
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
{
scanline=(unsigned char *) RelinquishMagickMemory(scanline);
image=DestroyImageList(image);
return((Image *) NULL);
}
Expand Down Expand Up @@ -399,6 +404,7 @@ static Image *ReadYUVImage(const ImageInfo *image_info,ExceptionInfo *exception)
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
{
scanline=(unsigned char *) RelinquishMagickMemory(scanline);
image=DestroyImageList(image);
return((Image *) NULL);
}
Expand Down Expand Up @@ -442,7 +448,10 @@ static Image *ReadYUVImage(const ImageInfo *image_info,ExceptionInfo *exception)
TriangleFilter,exception);
chroma_image=DestroyImage(chroma_image);
if (resize_image == (Image *) NULL)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
{
scanline=(unsigned char *) RelinquishMagickMemory(scanline);
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
}
for (y=0; y < (ssize_t) image->rows; y++)
{
q=GetAuthenticPixels(image,0,y,image->columns,1,exception);
Expand Down Expand Up @@ -491,6 +500,7 @@ static Image *ReadYUVImage(const ImageInfo *image_info,ExceptionInfo *exception)
AcquireNextImage(image_info,image,exception);
if (GetNextImageInList(image) == (Image *) NULL)
{
scanline=(unsigned char *) RelinquishMagickMemory(scanline);
image=DestroyImageList(image);
return((Image *) NULL);
}
Expand Down

0 comments on commit ef8f406

Please sign in to comment.