diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index 516163594d5..a57929c5f44 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -2619,7 +2619,7 @@ PHP_FUNCTION(simplexml_import_dom) nodep = xmlDocGetRootElement((xmlDocPtr) nodep); } - if (nodep->type == XML_ELEMENT_NODE) { + if (nodep && nodep->type == XML_ELEMENT_NODE) { if (!ce) { ce = sxe_class_entry; fptr_count = NULL; diff --git a/ext/simplexml/tests/bug81325.phpt b/ext/simplexml/tests/bug81325.phpt new file mode 100644 index 00000000000..b4010dd1f0c --- /dev/null +++ b/ext/simplexml/tests/bug81325.phpt @@ -0,0 +1,19 @@ +--TEST-- +BUg #81325 (segfault in zif_simplexml_import_dom) +--SKIPIF-- + +--FILE-- +loadXML("foo"); +$xml = simplexml_import_dom($dom); +?> +Done +--EXPECTF-- +Warning: DOMDocument::loadXML(): Start tag expected%s + +Warning: simplexml_import_dom(): Invalid Nodetype%s +Done