1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-03-09 04:58:16 +03:00

Fix memory leak in xmlSwitchInputEncodingInt error path

Found by OSS-Fuzz.
This commit is contained in:
Nick Wellnhofer 2018-11-22 15:27:28 +01:00
parent 1567b55b72
commit 3776cb4745

View File

@ -1240,8 +1240,18 @@ xmlSwitchInputEncodingInt(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
* size to be able to convert the buffer.
*/
xmlErrInternal(ctxt, "switching encoding : no input\n", NULL);
/*
* Callers assume that the input buffer takes ownership of the
* encoding handler. xmlCharEncCloseFunc frees unregistered
* handlers and avoids a memory leak.
*/
xmlCharEncCloseFunc(handler);
return (-1);
}
/*
* We should actually raise an error here, see issue #34.
*/
xmlCharEncCloseFunc(handler);
return (0);
}