mirror of
https://github.com/php/php-src.git
synced 2024-09-24 03:17:26 +00:00
fix #39662 (Segfault when calling asXML() of a cloned SimpleXMLElement)
This commit is contained in:
parent
7499bd74b6
commit
d2e03795d9
@ -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);
|
||||
|
58
ext/simplexml/tests/bug39662.phpt
Normal file
58
ext/simplexml/tests/bug39662.phpt
Normal 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
|
Loading…
Reference in New Issue
Block a user