]> granicus.if.org Git - imagemagick/commitdiff
XBM coder leaves the hex image data uninitialized if hex value of the pixel is negative
authorCristy <urban-warrior@imagemagick.org>
Tue, 24 Jul 2018 21:31:33 +0000 (17:31 -0400)
committerCristy <urban-warrior@imagemagick.org>
Tue, 24 Jul 2018 21:31:33 +0000 (17:31 -0400)
coders/xbm.c

index 34344b735e8dc832d6949e6b7bfeb098737a4ee9..bae47c8e59f5583a07412f0bd2c47dd369aa86c6 100644 (file)
@@ -351,7 +351,10 @@ static Image *ReadXBMImage(const ImageInfo *image_info,ExceptionInfo *exception)
     {
       c=XBMInteger(image,hex_digits);
       if (c < 0)
-        break;
+        {
+          data=(unsigned char *) RelinquishMagickMemory(data);
+          ThrowReaderException(CorruptImageError,"ImproperImageHeader");
+        }
       *p++=(unsigned char) c;
       if ((padding == 0) || (((i+2) % bytes_per_line) != 0))
         *p++=(unsigned char) (c >> 8);
@@ -361,7 +364,10 @@ static Image *ReadXBMImage(const ImageInfo *image_info,ExceptionInfo *exception)
     {
       c=XBMInteger(image,hex_digits);
       if (c < 0)
-        break;
+        {
+          data=(unsigned char *) RelinquishMagickMemory(data);
+          ThrowReaderException(CorruptImageError,"ImproperImageHeader");
+        }
       *p++=(unsigned char) c;
     }
   if (EOFBlob(image) != MagickFalse)