Embedded resource files losing the null-terminator
Posted: 2011-11-17T21:44:31-07:00
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.
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