diff options
author | Nick Wellnhofer <wellnhofer@aevum.de> | 2018-11-22 15:27:28 +0100 |
---|---|---|
committer | Nick Wellnhofer <wellnhofer@aevum.de> | 2018-11-22 16:28:46 +0100 |
commit | 3776cb4745cecd8f477b45857c9033a908f25cf3 (patch) | |
tree | 25cfdd327c382474650c8242022fe231cf89de70 /parserInternals.c | |
parent | 1567b55b72b8366ce120ed042e03ed5b50d191d7 (diff) | |
download | libxml2-3776cb4745cecd8f477b45857c9033a908f25cf3.tar.gz |
Fix memory leak in xmlSwitchInputEncodingInt error path
Found by OSS-Fuzz.
Diffstat (limited to 'parserInternals.c')
-rw-r--r-- | parserInternals.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/parserInternals.c b/parserInternals.c index 09876ab4..0f015ded 100644 --- a/parserInternals.c +++ b/parserInternals.c @@ -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); } |