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

Fix GH-17500: Segfault with requesting nodeName on nameless doctype

Closes GH-17344.
This commit is contained in:
Niels Dossche
2025-01-17 18:31:51 +01:00
parent 7da1ea4029
commit 82d71a82aa
3 changed files with 25 additions and 1 deletions

4
NEWS
View File

@@ -13,6 +13,10 @@ PHP NEWS
nielsdos)
. Fixed potential OOB when checking for trailing spaces on Windows. (cmb)
- DOM:
. Fixed bug GH-17500 (Segfault with requesting nodeName on nameless doctype).
(nielsdos)
- Enchant:
. Fix crashes in enchant when passing null bytes. (nielsdos)

View File

@@ -98,11 +98,17 @@ int 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) ""