summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-12-08 04:06:42 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-12-08 04:06:42 +0000
commit580c870e3fabbdd52bad109098ef569992c1d69c (patch)
tree517ae94e1fc5f487fd2c8f3986eb6e7bc2fc5cd0
parentbeaf92f7207ed6d94bf2df504e137d284502b747 (diff)
parentac7aa55a5cd612e3bdcbd54a0a2866f6ee1a4881 (diff)
downloadexpat-580c870e3fabbdd52bad109098ef569992c1d69c.tar.gz
Change-Id: I44def1370de2b6e68242cd67c76f77b7b57ad7a7
-rw-r--r--lib/xmlparse.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/xmlparse.c b/lib/xmlparse.c
index 729f94b8..381f3ef3 100644
--- a/lib/xmlparse.c
+++ b/lib/xmlparse.c
@@ -978,6 +978,14 @@ parserCreate(const XML_Char *encodingName,
parserInit(parser, encodingName);
if (encodingName && ! parser->m_protocolEncodingName) {
+ if (dtd) {
+ // We need to stop the upcoming call to XML_ParserFree from happily
+ // destroying parser->m_dtd because the DTD is shared with the parent
+ // parser and the only guard that keeps XML_ParserFree from destroying
+ // parser->m_dtd is parser->m_isParamEntity but it will be set to
+ // XML_TRUE only later in XML_ExternalEntityParserCreate (or not at all).
+ parser->m_dtd = NULL;
+ }
XML_ParserFree(parser);
return NULL;
}