Skip to content

Commit d3c95db

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fix #78025: segfault when accessing properties of DOMDocumentType
2 parents bd1bd38 + fd60763 commit d3c95db

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

ext/dom/documenttype.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ int dom_documenttype_name_read(dom_object *obj, zval *retval)
5050
return FAILURE;
5151
}
5252

53-
ZVAL_STRING(retval, (char *) (dtdptr->name));
53+
ZVAL_STRING(retval, dtdptr->name ? (char *) (dtdptr->name) : "");
5454

5555
return SUCCESS;
5656
}

ext/dom/tests/bug78025.phpt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Bug #78025 (segfault when accessing properties of DOMDocumentType)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('dom')) die('skip dom extension not available');
6+
?>
7+
--FILE--
8+
<?php
9+
$htm = "<!DOCTYPE><html></html>";
10+
$dom = new DOMDocument;
11+
$dom->loadHTML($htm);
12+
var_dump($dom->doctype->name);
13+
?>
14+
===DONE===
15+
--EXPECTF--
16+
Warning: DOMDocument::loadHTML(): htmlParseDocTypeDecl : no DOCTYPE name ! in Entity, line: 1 in %s on line %d
17+
string(0) ""
18+
===DONE===

0 commit comments

Comments
 (0)