Skip to content

Commit 2c7fb35

Browse files
author
Scott MacVicar
committed
Fix use after free() in XMLReader::xml()
1 parent 194b480 commit 2c7fb35

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

ext/xmlreader/php_xmlreader.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#ifdef HAVE_DOM
3131
#include "ext/dom/xml_common.h"
3232
#endif
33+
#include <libxml/xmlreader.h>
3334
#include <libxml/uri.h>
3435

3536
zend_class_entry *xmlreader_class_entry;
@@ -1091,9 +1092,7 @@ PHP_METHOD(xmlreader, XML)
10911092
uri = (char *) xmlCanonicPath((const xmlChar *) resolved_path);
10921093
}
10931094
reader = xmlNewTextReader(inputbfr, uri);
1094-
if (uri) {
1095-
xmlFree(uri);
1096-
}
1095+
10971096
if (reader != NULL) {
10981097
#if LIBXML_VERSION >= 20628
10991098
ret = xmlTextReaderSetup(reader, NULL, uri, encoding, options);
@@ -1107,11 +1106,20 @@ PHP_METHOD(xmlreader, XML)
11071106
}
11081107
intern->input = inputbfr;
11091108
intern->ptr = reader;
1109+
1110+
if (uri) {
1111+
xmlFree(uri);
1112+
}
1113+
11101114
return;
11111115
}
11121116
}
11131117
}
11141118

1119+
if (uri) {
1120+
xmlFree(uri);
1121+
}
1122+
11151123
if (inputbfr) {
11161124
xmlFreeParserInputBuffer(inputbfr);
11171125
}

0 commit comments

Comments
 (0)