[libxml2] Reset XML parser input before reporting errors



commit 0e5c4fec15dd08115c8a2708dee0127b28a8410e
Author: David Kilzer <ddkilzer apple com>
Date:   Mon Jul 13 15:20:45 2020 -0700

    Reset XML parser input before reporting errors
    
    Apply changes to htmlParseChunk() in 13ba5b61 and 3f18e748 to
    xmlParseChunk().

 parser.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/parser.c b/parser.c
index 1932e57a7..e1d139d5d 100644
--- a/parser.c
+++ b/parser.c
@@ -12234,12 +12234,12 @@ xmldecl_done:
             }
         }
        res = xmlParserInputBufferPush(ctxt->input->buf, size, chunk);
+        xmlBufSetInputBaseCur(ctxt->input->buf->buffer, ctxt->input, base, cur);
        if (res < 0) {
            ctxt->errNo = XML_PARSER_EOF;
            xmlHaltParser(ctxt);
            return (XML_PARSER_EOF);
        }
-        xmlBufSetInputBaseCur(ctxt->input->buf->buffer, ctxt->input, base, cur);
 #ifdef DEBUG_PUSH
        xmlGenericError(xmlGenericErrorContext, "PP: pushed %d\n", size);
 #endif
@@ -12254,6 +12254,7 @@ xmldecl_done:
                size_t current = ctxt->input->cur - ctxt->input->base;
 
                nbchars = xmlCharEncInput(in, terminate);
+               xmlBufSetInputBaseCur(in->buffer, ctxt->input, base, current);
                if (nbchars < 0) {
                    /* TODO 2.6.0 */
                    xmlGenericError(xmlGenericErrorContext,
@@ -12261,7 +12262,6 @@ xmldecl_done:
                     xmlHaltParser(ctxt);
                    return(XML_ERR_INVALID_ENCODING);
                }
-               xmlBufSetInputBaseCur(in->buffer, ctxt->input, base, current);
            }
        }
     }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]