diff --git a/parser.c b/parser.c index b41dcc3..e415339 100644 --- a/parser.c +++ b/parser.c @@ -10130,12 +10130,8 @@ xmlParseDocument(xmlParserCtxtPtr ctxt) { /* * Check for the XMLDecl in the Prolog. * do not GROW here to avoid the detected encoder to decode more - * than just the first line, unless the amount of data is really - * too small to hold "input->end - ctxt->input->cur) < 35) { - GROW; - } if ((CMP5(CUR_PTR, '<', '?', 'x', 'm', 'l')) && (IS_BLANK_CH(NXT(5)))) { /* diff --git a/xmlIO.c b/xmlIO.c index c03ac43..1e7d213 100644 --- a/xmlIO.c +++ b/xmlIO.c @@ -3149,7 +3149,11 @@ xmlParserInputBufferGrow(xmlParserInputBufferPtr in, int len) { * Call the read method for this I/O type. */ if (in->readcallback != NULL) { - res = in->readcallback(in->context, &buffer[0], len); + nbchars = 0; + while (len && (res = in->readcallback(in->context, &buffer[nbchars], len)) > 0) { + nbchars += res; + len -= res; + } if (res <= 0) in->readcallback = endOfInput; } else { @@ -3160,7 +3164,7 @@ xmlParserInputBufferGrow(xmlParserInputBufferPtr in, int len) { if (res < 0) { return(-1); } - len = res; + len = nbchars; if (in->encoder != NULL) { unsigned int use;