1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merge branch 'PHP-8.3' into PHP-8.4

* PHP-8.3:
  Fix GH-17500: Segfault with requesting nodeName on nameless doctype
This commit is contained in:
Niels Dossche
2025-01-17 19:37:14 +01:00
3 changed files with 23 additions and 1 deletions

2
NEWS
View File

@@ -22,6 +22,8 @@ PHP NEWS
. Fixed bug GH-17486 (Incorrect error line numbers reported in
Dom\HTMLDocument::createFromString). (nielsdos)
. Fixed bug GH-17481 (UTF-8 corruption in \Dom\HTMLDocument). (nielsdos)
. Fixed bug GH-17500 (Segfault with requesting nodeName on nameless doctype).
(nielsdos)
- Enchant:
. Fix crashes in enchant when passing null bytes. (nielsdos)

View File

@@ -102,11 +102,17 @@ zend_result dom_node_node_name_read(dom_object *obj, zval *retval)
}
case XML_DOCUMENT_TYPE_NODE:
case XML_DTD_NODE:
if (nodep->name) {
ZVAL_STRING(retval, (const char *) nodep->name);
} else {
ZVAL_EMPTY_STRING(retval);
}
break;
case XML_PI_NODE:
case XML_ENTITY_DECL:
case XML_ENTITY_REF_NODE:
case XML_NOTATION_NODE:
ZVAL_STRING(retval, (char *) nodep->name);
ZVAL_STRING(retval, (const char *) nodep->name);
break;
case XML_CDATA_SECTION_NODE:
ZVAL_STRING(retval, "#cdata-section");

View File

@@ -0,0 +1,14 @@
--TEST--
GH-17500 (Segfault with requesting nodeName on nameless doctype)
--EXTENSIONS--
dom
--FILE--
<?php
$doc = new DOMDocument();
$doc->loadHTML("<!DOCTYPE>", LIBXML_NOERROR);
var_dump($doc->doctype->nodeName);
?>
--EXPECT--
string(0) ""