1
0
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:
David CARLIER
2024-06-24 22:31:53 +01:00
committed by GitHub
parent 835cb69ab5
commit 5c55306a50
2 changed files with 21 additions and 1 deletions

View File

@@ -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);
}
}
}

View 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"