1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-10-26 20:25:14 +03:00

Reset parser input pointers on encoding failure

Call xmlBufResetInput before bailing out if switching the encoding
fails. Otherwise, the input pointers are left in an invalid state.
This would typically lead to an internal error in xmlGROW but could also
cause other unforeseen problems.
This commit is contained in:
Nick Wellnhofer 2017-06-10 00:33:07 +02:00
parent bedbef8065
commit f9e7997e80

View File

@ -1233,6 +1233,7 @@ xmlSwitchInputEncodingInt(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
*/
nbchars = xmlCharEncFirstLineInput(input->buf, len);
}
xmlBufResetInput(input->buf->buffer, input);
if (nbchars < 0) {
xmlErrInternal(ctxt,
"switching encoding: encoder error\n",
@ -1240,7 +1241,6 @@ xmlSwitchInputEncodingInt(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
return (-1);
}
input->buf->rawconsumed += use - xmlBufUse(input->buf->raw);
xmlBufResetInput(input->buf->buffer, input);
}
return (0);
} else if (input->length == 0) {