Page 1 of 1

Embedded resource files losing the null-terminator

Posted: 2011-11-17T21:44:31-07:00
by Ravana
I found a bug when loading embedded xml resource files.

StringInfo->datum will later be passed to NewXMLTree() who expects it to be null-terminated.
StringToStringInfo() strips the trailing null, so instead do what ConfigureFileToStringInfo() does when loading from a file.

Code: Select all

Index: MagickCore/configure.c
===================================================================
--- MagickCore/configure.c	(revision 5993)
+++ MagickCore/configure.c	(working copy)
@@ -581,10 +581,11 @@
     blob=(char *) NTResourceToBlob(filename);
     if (blob != (char *) NULL)
       {
-        xml=StringToStringInfo(blob);
+        xml=AcquireStringInfo(0);
+        xml->length=strlen(blob)+1;
+        xml->datum=(unsigned char *) blob;
         SetStringInfoPath(xml,filename);
         (void) AppendValueToLinkedList(options,xml);
-        blob=DestroyString(blob);
       }
   }
 #endif

Re: Embedded resource files losing the null-terminator

Posted: 2011-11-18T05:53:13-07:00
by magick
Thanks for the bug report and patch. We'll get the patch into the next point release of ImageMagick.