mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Fix GH-14652: segfault on node without document. (#14653)
do not bother trying to clone the inner document if there is none to begin with.
This commit is contained in:
@@ -600,7 +600,9 @@ static zend_object *dom_objects_store_clone_obj(zend_object *zobject) /* {{{ */
|
||||
if (cloned_node != NULL) {
|
||||
dom_update_refcount_after_clone(intern, node, clone, cloned_node);
|
||||
}
|
||||
clone->document->private_data = php_dom_libxml_ns_mapper_header(ns_mapper);
|
||||
if (ns_mapper != NULL) {
|
||||
clone->document->private_data = php_dom_libxml_ns_mapper_header(ns_mapper);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
18
ext/dom/tests/gh14652.phpt
Normal file
18
ext/dom/tests/gh14652.phpt
Normal file
@@ -0,0 +1,18 @@
|
||||
--TEST--
|
||||
GH-14652 segfault on object cloning
|
||||
--EXTENSIONS--
|
||||
dom
|
||||
--CREDITS--
|
||||
YuanchengJiang
|
||||
--FILE--
|
||||
<?php
|
||||
$attr = new DOMAttr('category', 'books');
|
||||
$clone = clone $attr;
|
||||
$attr->value = "hello";
|
||||
|
||||
var_dump($attr->value);
|
||||
var_dump($clone->value);
|
||||
?>
|
||||
--EXPECT--
|
||||
string(5) "hello"
|
||||
string(5) "books"
|
||||
Reference in New Issue
Block a user