|
|
f74686 |
From babe75030c7f64a37826bb3342317134568bef61 Mon Sep 17 00:00:00 2001
|
|
|
f74686 |
From: Nick Wellnhofer <wellnhofer@aevum.de>
|
|
|
f74686 |
Date: Sat, 1 May 2021 16:53:33 +0200
|
|
|
f74686 |
Subject: [PATCH] Propagate error in xmlParseElementChildrenContentDeclPriv
|
|
|
f74686 |
|
|
|
f74686 |
Check return value of recursive calls to
|
|
|
f74686 |
xmlParseElementChildrenContentDeclPriv and return immediately in case
|
|
|
f74686 |
of errors. Otherwise, struct xmlElementContent could contain unexpected
|
|
|
f74686 |
null pointers, leading to a null deref when post-validating documents
|
|
|
f74686 |
which aren't well-formed and parsed in recovery mode.
|
|
|
f74686 |
|
|
|
f74686 |
Fixes #243.
|
|
|
f74686 |
---
|
|
|
f74686 |
parser.c | 7 +++++++
|
|
|
f74686 |
1 file changed, 7 insertions(+)
|
|
|
f74686 |
|
|
|
f74686 |
diff --git a/parser.c b/parser.c
|
|
|
f74686 |
index b42e6043..73c27edd 100644
|
|
|
f74686 |
--- a/parser.c
|
|
|
f74686 |
+++ b/parser.c
|
|
|
f74686 |
@@ -6208,6 +6208,8 @@ xmlParseElementChildrenContentDeclPriv(xmlParserCtxtPtr ctxt, int inputchk,
|
|
|
f74686 |
SKIP_BLANKS;
|
|
|
f74686 |
cur = ret = xmlParseElementChildrenContentDeclPriv(ctxt, inputid,
|
|
|
f74686 |
depth + 1);
|
|
|
f74686 |
+ if (cur == NULL)
|
|
|
f74686 |
+ return(NULL);
|
|
|
f74686 |
SKIP_BLANKS;
|
|
|
f74686 |
GROW;
|
|
|
f74686 |
} else {
|
|
|
f74686 |
@@ -6341,6 +6343,11 @@ xmlParseElementChildrenContentDeclPriv(xmlParserCtxtPtr ctxt, int inputchk,
|
|
|
f74686 |
SKIP_BLANKS;
|
|
|
f74686 |
last = xmlParseElementChildrenContentDeclPriv(ctxt, inputid,
|
|
|
f74686 |
depth + 1);
|
|
|
f74686 |
+ if (last == NULL) {
|
|
|
f74686 |
+ if (ret != NULL)
|
|
|
f74686 |
+ xmlFreeDocElementContent(ctxt->myDoc, ret);
|
|
|
f74686 |
+ return(NULL);
|
|
|
f74686 |
+ }
|
|
|
f74686 |
SKIP_BLANKS;
|
|
|
f74686 |
} else {
|
|
|
f74686 |
elem = xmlParseName(ctxt);
|
|
|
f74686 |
--
|
|
|
f74686 |
GitLab
|
|
|
f74686 |
|