fix #39662 (Segfault when calling asXML() of a cloned SimpleXMLElement)

This commit is contained in:
Antony Dovgal 2006-11-28 18:57:37 +00:00
parent 7499bd74b6
commit d2e03795d9
2 changed files with 59 additions and 0 deletions

View File

@ -1784,6 +1784,7 @@ sxe_object_clone(void *object, void **clone_ptr TSRMLS_DC)
}
if (sxe->node) {
nodep = xmlDocCopyNode(sxe->node->node, docp, 1);
nodep->parent = sxe->node->node->parent;
}
php_libxml_increment_node_ptr((php_libxml_node_object *)clone, nodep, NULL TSRMLS_CC);

View File

@ -0,0 +1,58 @@
--TEST--
Bug #39662 (Segfault when calling asXML() of a cloned SimpleXMLElement)
--SKIPIF--
<?php if (!extension_loaded("simplexml")) print "skip simplexml extension is not loaded"; ?>
--FILE--
<?php
$xml = b'<?xml version="1.0" encoding="utf-8" ?>
<test>
</test>';
$root = simplexml_load_string($xml);
$clone = clone $root;
var_dump($root);
var_dump($clone);
var_dump($clone->asXML());
echo "Done\n";
?>
--EXPECTF--
object(SimpleXMLElement)#%d (1) {
[0]=>
string(2) "
"
}
object(SimpleXMLElement)#%d (1) {
[0]=>
string(2) "
"
}
string(55) "<?xml version="1.0" encoding="utf-8"?>
<test>
</test>
"
Done
--UEXPECTF--
object(SimpleXMLElement)#%d (1) {
[0]=>
unicode(2) "
"
}
object(SimpleXMLElement)#%d (1) {
[0]=>
unicode(2) "
"
}
string(55) "<?xml version="1.0" encoding="utf-8"?>
<test>
</test>
"
Done