File ImageMagick-CVE-2018-5247.patch of Package ImageMagick.16891
Index: ImageMagick-6.8.8-1/coders/rla.c
===================================================================
--- ImageMagick-6.8.8-1.orig/coders/rla.c 2013-12-01 15:47:50.000000000 +0100
+++ ImageMagick-6.8.8-1/coders/rla.c 2018-01-09 10:45:04.238489498 +0100
@@ -278,7 +278,10 @@ static Image *ReadRLAImage(const ImageIn
{
offset=SeekBlob(image,scanlines[image->rows-y-1],SEEK_SET);
if (offset < 0)
- ThrowReaderException(CorruptImageError,"ImproperImageHeader");
+ {
+ scanlines=(MagickOffsetType *) RelinquishMagickMemory(scanlines);
+ ThrowReaderException(CorruptImageError,"ImproperImageHeader");
+ }
for (channel=0; channel < (int) rla_info.number_channels; channel++)
{
length=(int) ReadBlobMSBShort(image);
@@ -378,6 +381,7 @@ static Image *ReadRLAImage(const ImageIn
if (status == MagickFalse)
break;
}
+ scanlines=(MagickOffsetType *) RelinquishMagickMemory(scanlines);
if (EOFBlob(image) != MagickFalse)
ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
image->filename);