1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-10-24 13:33:01 +03:00

malloc-fail: Fix null deref in xmlBufResize

Found with libFuzzer, see #344.
This commit is contained in:
Nick Wellnhofer
2023-01-22 13:20:15 +01:00
parent b3b53dcce4
commit 1aabc9db40

3
buf.c
View File

@@ -735,7 +735,8 @@ xmlBufResize(xmlBufPtr buf, size_t size)
if (buf->content == NULL) {
rebuf = (xmlChar *) xmlMallocAtomic(newSize);
buf->use = 0;
rebuf[buf->use] = 0;
if (rebuf != NULL)
rebuf[buf->use] = 0;
} else if (buf->size - buf->use < 100) {
rebuf = (xmlChar *) xmlRealloc(buf->content, newSize);
} else {