mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-03-09 04:58:16 +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:
parent
bedbef8065
commit
f9e7997e80
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user