1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-03-25 10:50:08 +03:00

malloc-fail: Fix memory leak in xmlOutputBufferCreateFilename

Close encoding handler on error.
This commit is contained in:
Nick Wellnhofer 2024-07-26 18:07:27 +02:00
parent 02fcb1effb
commit 36ea881b9d

12
xmlIO.c
View File

@ -1523,11 +1523,12 @@ __xmlOutputBufferCreateFilename(const char *URI,
*/
if (puri->scheme == NULL) {
unescaped = xmlURIUnescapeString(URI, 0, NULL);
if (unescaped == NULL) {
xmlFreeURI(puri);
return(NULL);
}
URI = unescaped;
if (unescaped == NULL) {
xmlFreeURI(puri);
xmlCharEncCloseFunc(encoder);
return(NULL);
}
URI = unescaped;
}
xmlFreeURI(puri);
}
@ -1538,6 +1539,7 @@ __xmlOutputBufferCreateFilename(const char *URI,
ret = xmlAllocOutputBufferInternal(encoder);
if (ret == NULL) {
xmlFree(unescaped);
xmlCharEncCloseFunc(encoder);
return(NULL);
}