Skip to content

Commit

Permalink
Merge branch 'PHP-8.0'
Browse files Browse the repository at this point in the history
* PHP-8.0:
  NEWS
  Fix bug #81325  Segfault in zif_simplexml_import_dom
  • Loading branch information
remicollet committed Aug 3, 2021
2 parents 467504c + 35c3e0b commit a48bf8a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ext/simplexml/simplexml.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
19 changes: 19 additions & 0 deletions ext/simplexml/tests/bug81325.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--TEST--
BUg #81325 (segfault in zif_simplexml_import_dom)
--SKIPIF--
<?php
if (!extension_loaded('simplexml')) die('skip simplexml not available');
if (!extension_loaded('dom')) die('skip simplexml not available');
?>
--FILE--
<?php
$dom = new DOMDocument;
$dom->loadXML("foo");
$xml = simplexml_import_dom($dom);
?>
Done
--EXPECTF--
Warning: DOMDocument::loadXML(): Start tag expected%s

Warning: simplexml_import_dom(): Invalid Nodetype%s
Done

0 comments on commit a48bf8a

Please sign in to comment.