• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1From e2d37972e41224b11ff76f3a9fd689207b6108a6 Mon Sep 17 00:00:00 2001
2From: Nick Wellnhofer <wellnhofer@aevum.de>
3Date: Sun, 20 Nov 2022 15:35:49 +0100
4Subject: [PATCH 21/28] parser: Fix push parser with 1-3 byte initial chunk
5
6Make sure that ctxt->charset is initialized properly.
7
8Reference: https://github.com/GNOME/libxml2/commit/55fb8f72ac726b4f760136070e0d2093ffcdb3ac
9Conflict: NA
10---
11 parser.c | 7 ++++---
12 1 file changed, 4 insertions(+), 3 deletions(-)
13
14diff --git a/parser.c b/parser.c
15index 7553f86..4615db0 100644
16--- a/parser.c
17+++ b/parser.c
18@@ -12523,9 +12523,10 @@ xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax, void *user_data,
19      * the encoding, we set the context to XML_CHAR_ENCODING_NONE so
20      * that it can be automatically determined later
21      */
22-    if ((size == 0) || (chunk == NULL)) {
23-	ctxt->charset = XML_CHAR_ENCODING_NONE;
24-    } else if ((ctxt->input != NULL) && (ctxt->input->buf != NULL)) {
25+    ctxt->charset = XML_CHAR_ENCODING_NONE;
26+
27+    if ((size != 0) && (chunk != NULL) &&
28+        (ctxt->input != NULL) && (ctxt->input->buf != NULL)) {
29 	size_t base = xmlBufGetInputBase(ctxt->input->buf->buffer, ctxt->input);
30 	size_t cur = ctxt->input->cur - ctxt->input->base;
31
32--
332.27.0
34
35