1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-10-24 13:33:01 +03:00

encoding: Move rawconsumed accounting to xmlCharEncInput

This commit is contained in:
Nick Wellnhofer
2023-08-08 15:19:51 +02:00
parent a0462e2d54
commit 4ee0815514
3 changed files with 6 additions and 29 deletions

View File

@@ -1414,7 +1414,7 @@ xmlSwitchInputEncoding(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
* Is there already some content down the pipe to convert ?
*/
if (xmlBufIsEmpty(in->buffer) == 0) {
size_t processed, use, consumed;
size_t processed;
/*
* Shrink the current input buffer.
@@ -1426,7 +1426,6 @@ xmlSwitchInputEncoding(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
in->raw = in->buffer;
in->buffer = xmlBufCreate();
in->rawconsumed = processed;
use = xmlBufUse(in->raw);
/*
* TODO: We must flush and decode the whole buffer to make functions
@@ -1448,12 +1447,6 @@ xmlSwitchInputEncoding(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
xmlHaltParser(ctxt);
return (-1);
}
consumed = use - xmlBufUse(in->raw);
if ((consumed > ULONG_MAX) ||
(in->rawconsumed > ULONG_MAX - (unsigned long)consumed))
in->rawconsumed = ULONG_MAX;
else
in->rawconsumed += consumed;
}
return (0);
}