summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Wellnhofer <wellnhofer@aevum.de>2023-03-16 17:50:53 +0100
committerNick Wellnhofer <wellnhofer@aevum.de>2023-03-16 17:52:20 +0100
commitc401ed2166493eeaf5d00dc47fe139a6f47fd5cf (patch)
treed699a4ca4496e742716c18c6bad013cfa3e86d5b
parent5d452a61d3580054c45501f761f233d34b8a29d3 (diff)
downloadlibxslt-c401ed2166493eeaf5d00dc47fe139a6f47fd5cf.tar.gz
transform: Avoid null deref on documents without root node
Documents should always have a root node, but we shouldn't segfault if it's missing. Found by OSS-Fuzz.
-rw-r--r--libxslt/transform.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/libxslt/transform.c b/libxslt/transform.c
index d7992605..0fc0400c 100644
--- a/libxslt/transform.c
+++ b/libxslt/transform.c
@@ -5767,6 +5767,8 @@ xsltCleanupSourceDoc(xmlDocPtr doc) {
if (cur->children != NULL && cur->type != XML_ENTITY_REF_NODE) {
cur = cur->children;
} else {
+ if (cur == (xmlNodePtr) doc)
+ return;
while (cur->next == NULL) {
cur = cur->parent;
if (cur == (xmlNodePtr) doc)