Closed WaterJuice closed 2 years ago
Will consider this for a future release, however mxmlSaveString
is not documented to support passing a NULL buffer pointer. As for computing the size for allocation, that's why I provided mxmlSaveAllocString
.
[master 3a4ece2] Fix mxmlSaveString with a 0-length buffer (Issue #284)
mxmlSaveString in theory can be used to determine the length of the XML string without writing to a buffer. You might want to do this first to determine the length of the buffer to allocate. If you pass it a NULL buffer with bufsize 0 it will crash, but only because it attempts to zero terminate the string at the end.
https://github.com/michaelrsweet/mxml/blob/990d4b54ea917174b16f89065fb61b1ebb5cc563/mxml-file.c#L379
This line will cause the crash. In my version I have patched this to wrap the line with
if(bufsize > 0)
This prevents the crash and makes the function usable for simply determining length of string.