mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Merge branch 'PHP-8.4'
* PHP-8.4: Fix GH-16039: Segmentation fault (access null pointer) in ext/dom/parentnode/tree.c
This commit is contained in:
@@ -379,6 +379,11 @@ xmlNode* dom_zvals_to_single_node(php_libxml_ref_obj *document, xmlNode *context
|
||||
newNodeObj = Z_DOMOBJ_P(&nodes[i]);
|
||||
newNode = dom_object_get_node(newNodeObj);
|
||||
|
||||
if (UNEXPECTED(!newNode)) {
|
||||
php_dom_throw_error(INVALID_STATE_ERR, /* strict */ true);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!dom_is_pre_insert_valid_without_step_1(document, node, newNode, NULL, documentNode)) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
31
ext/dom/tests/gh16039.phpt
Normal file
31
ext/dom/tests/gh16039.phpt
Normal file
@@ -0,0 +1,31 @@
|
||||
--TEST--
|
||||
GH-16039 (Segmentation fault (access null pointer) in ext/dom/parentnode/tree.c)
|
||||
--EXTENSIONS--
|
||||
dom
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$dom = new DOMDocument;
|
||||
$element = $dom->appendChild($dom->createElement('root'));
|
||||
try {
|
||||
$element->prepend('x', new DOMEntity);
|
||||
} catch (DOMException $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
echo $dom->saveXML();
|
||||
$dom->strictErrorChecking = false; // Should not have influence
|
||||
try {
|
||||
$element->prepend('x', new DOMEntity);
|
||||
} catch (DOMException $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
echo $dom->saveXML();
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
Invalid State Error
|
||||
<?xml version="1.0"?>
|
||||
<root/>
|
||||
Invalid State Error
|
||||
<?xml version="1.0"?>
|
||||
<root/>
|
||||
Reference in New Issue
Block a user