File ImageMagick-CVE-2017-15033.patch of Package ImageMagick.5842
Index: ImageMagick-6.8.8-1/coders/yuv.c
===================================================================
--- ImageMagick-6.8.8-1.orig/coders/yuv.c 2013-12-01 15:47:50.000000000 +0100
+++ ImageMagick-6.8.8-1/coders/yuv.c 2017-10-06 14:51:12.525882753 +0200
@@ -206,7 +206,10 @@ static Image *ReadYUVImage(const ImageIn
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.
*/
@@ -219,6 +222,7 @@ static Image *ReadYUVImage(const ImageIn
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
{
+ scanline=(unsigned char *) RelinquishMagickMemory(scanline);
image=DestroyImageList(image);
return((Image *) NULL);
}
@@ -324,6 +328,7 @@ static Image *ReadYUVImage(const ImageIn
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
{
+ scanline=(unsigned char *) RelinquishMagickMemory(scanline);
image=DestroyImageList(image);
return((Image *) NULL);
}
@@ -361,6 +366,7 @@ static Image *ReadYUVImage(const ImageIn
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
{
+ scanline=(unsigned char *) RelinquishMagickMemory(scanline);
image=DestroyImageList(image);
return((Image *) NULL);
}
@@ -395,7 +401,10 @@ static Image *ReadYUVImage(const ImageIn
TriangleFilter,1.0,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);
@@ -443,6 +452,7 @@ static Image *ReadYUVImage(const ImageIn
AcquireNextImage(image_info,image);
if (GetNextImageInList(image) == (Image *) NULL)
{
+ scanline=(unsigned char *) RelinquishMagickMemory(scanline);
image=DestroyImageList(image);
return((Image *) NULL);
}