Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 82d71a8

Browse files
committed
Fix GH-17500: Segfault with requesting nodeName on nameless doctype
Closes GH-17344.
1 parent 7da1ea4 commit 82d71a8

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

‎NEWS‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ PHP NEWS
1313
nielsdos)
1414
. Fixed potential OOB when checking for trailing spaces on Windows. (cmb)
1515

16+
- DOM:
17+
. Fixed bug GH-17500 (Segfault with requesting nodeName on nameless doctype).
18+
(nielsdos)
19+
1620
- Enchant:
1721
. Fix crashes in enchant when passing null bytes. (nielsdos)
1822

‎ext/dom/node.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,17 @@ int dom_node_node_name_read(dom_object *obj, zval *retval)
9898
}
9999
case XML_DOCUMENT_TYPE_NODE:
100100
case XML_DTD_NODE:
101+
if (nodep->name) {
102+
ZVAL_STRING(retval, (const char *) nodep->name);
103+
} else {
104+
ZVAL_EMPTY_STRING(retval);
105+
}
106+
break;
101107
case XML_PI_NODE:
102108
case XML_ENTITY_DECL:
103109
case XML_ENTITY_REF_NODE:
104110
case XML_NOTATION_NODE:
105-
ZVAL_STRING(retval, (char *) nodep->name);
111+
ZVAL_STRING(retval, (constchar *) nodep->name);
106112
break;
107113
case XML_CDATA_SECTION_NODE:
108114
ZVAL_STRING(retval, "#cdata-section");

‎ext/dom/tests/gh17500.phpt‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
GH-17500 (Segfault with requesting nodeName on nameless doctype)
3+
--EXTENSIONS--
4+
dom
5+
--FILE--
6+
<?php
7+
8+
$doc = new DOMDocument();
9+
$doc->loadHTML("<!DOCTYPE>", LIBXML_NOERROR);
10+
var_dump($doc->doctype->nodeName);
11+
12+
?>
13+
--EXPECT--
14+
string(0) ""

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /