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

Fix an off by one error in encoding

this off by one error doesn't seems to reproduce on linux
but the error is real.
This commit is contained in:
Daniel Veillard 2011-08-19 11:05:04 +08:00
parent d7eb9b5d47
commit 69f04562f7

View File

@ -1928,7 +1928,7 @@ xmlCharEncFirstLineInt(xmlCharEncodingHandler *handler, xmlBufferPtr out,
if (in == NULL) return(-1);
/* calculate space available */
written = out->size - out->use;
written = out->size - out->use - 1; /* count '\0' */
toconv = in->use;
/*
* echo '<?xml version="1.0" encoding="UCS4"?>' | wc -c => 38
@ -2059,7 +2059,7 @@ xmlCharEncInFunc(xmlCharEncodingHandler * handler, xmlBufferPtr out,
toconv = in->use;
if (toconv == 0)
return (0);
written = out->size - out->use;
written = out->size - out->use -1; /* count '\0' */
if (toconv * 2 >= written) {
xmlBufferGrow(out, out->size + toconv * 2);
written = out->size - out->use - 1;