From 3eef3f39a646f279e88cdb2fc45b6b17211fcd74 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Tue, 20 Jun 2017 16:13:57 +0200 Subject: [PATCH] Fix NULL deref in xmlParseExternalEntityPrivate If called from xmlParseExternalEntity, oldctxt is NULL which leads to a NULL deref if an error occurs. This only affects external code that calls xmlParseExternalEntity. Patch from David Kilzer with minor changes. Fixes bug 780159. --- parser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parser.c b/parser.c index f561e2fc..cfc5b8e0 100644 --- a/parser.c +++ b/parser.c @@ -13224,7 +13224,7 @@ xmlParseExternalEntityPrivate(xmlDocPtr doc, xmlParserCtxtPtr oldctxt, /* * And record the last error if any */ - if (ctxt->lastError.code != XML_ERR_OK) + if ((oldctxt != NULL) && (ctxt->lastError.code != XML_ERR_OK)) xmlCopyError(&ctxt->lastError, &oldctxt->lastError); if (sax != NULL)