summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2019-05-17 13:31:18 +0200
committerChristoph M. Becker <cmbecker69@gmx.de>2019-05-17 13:31:18 +0200
commite246dea9fe4d679f20de298c753d9ad083dbad68 (patch)
tree3cf94c2cf2c1336fec08d0bfdaf9d1d4eb5b4e22
parent35353dc49a73a58c17c7896c4c4c3997ef2c007d (diff)
downloadphp-git-e246dea9fe4d679f20de298c753d9ad083dbad68.tar.gz
Fix #78025: segfault when accessing properties of DOMDocumentType
Instead of following the NULL pointer, we return an empty string.
-rw-r--r--NEWS4
-rw-r--r--ext/dom/documenttype.c2
-rw-r--r--ext/dom/tests/bug78025.phpt18
3 files changed, 23 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index eb52e5261d..2135a42e0e 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,10 @@ PHP NEWS
. Fixed bug #76980 (Interface gets skipped if autoloader throws an exception).
(Nikita)
+- DOM:
+ . Fixed bug #78025 (segfault when accessing properties of DOMDocumentType).
+ (cmb)
+
30 May 2019, PHP 7.2.19
- FPM:
diff --git a/ext/dom/documenttype.c b/ext/dom/documenttype.c
index 661d23d1c9..d261d267fc 100644
--- a/ext/dom/documenttype.c
+++ b/ext/dom/documenttype.c
@@ -52,7 +52,7 @@ int dom_documenttype_name_read(dom_object *obj, zval *retval)
return FAILURE;
}
- ZVAL_STRING(retval, (char *) (dtdptr->name));
+ ZVAL_STRING(retval, dtdptr->name ? (char *) (dtdptr->name) : "");
return SUCCESS;
}
diff --git a/ext/dom/tests/bug78025.phpt b/ext/dom/tests/bug78025.phpt
new file mode 100644
index 0000000000..0a12d9f42f
--- /dev/null
+++ b/ext/dom/tests/bug78025.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Bug #78025 (segfault when accessing properties of DOMDocumentType)
+--SKIPIF--
+<?php
+if (!extension_loaded('dom')) die('skip dom extension not available');
+?>
+--FILE--
+<?php
+$htm = "<!DOCTYPE><html></html>";
+$dom = new DOMDocument;
+$dom->loadHTML($htm);
+var_dump($dom->doctype->name);
+?>
+===DONE===
+--EXPECTF--
+Warning: DOMDocument::loadHTML(): htmlParseDocTypeDecl : no DOCTYPE name ! in Entity, line: 1 in %s on line %d
+string(0) ""
+===DONE===