Fix mxmlSaveString with a 0-length buffer (Issue #284)

This commit is contained in:
Michael R Sweet 2021-10-26 14:44:15 -04:00
parent bd4eb861a7
commit 3a4ece2266
No known key found for this signature in database
GPG Key ID: 999559A027815955
2 changed files with 5 additions and 1 deletions

View File

@ -1,6 +1,7 @@
# Changes in Mini-XML 3.2.1
- Fixed potential memory leak in `mxmlLoad*` functions (Issue #278, Issue #279)
- Fixed `mxmlSaveString` with a buffer size of 0 (Issue #284)
- Fixed `MXML_MINOR_VERSION` value in "mxml.h" (Issue #285)
- Fixed POSIX threading support for MingW (Issue #287)
- Fixed some minor memory leaks found by Coverity.

View File

@ -376,7 +376,10 @@ mxmlSaveString(mxml_node_t *node, /* I - Node to write */
*/
if (ptr[0] >= ptr[1])
buffer[bufsize - 1] = '\0';
{
if (bufsize > 0)
buffer[bufsize - 1] = '\0';
}
else
ptr[0][0] = '\0';