summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2020-02-14 10:55:17 +0100
committerChristoph M. Becker <cmbecker69@gmx.de>2020-02-17 09:07:54 +0100
commit09669411309b5c18c48b550d89b34e78983118cd (patch)
treeb91a87e1a622db6b59415d098a6fd7d6a55832b5
parent392dada1d64e67508304482efb107c5932d995b0 (diff)
downloadphp-git-09669411309b5c18c48b550d89b34e78983118cd.tar.gz
Fix #79271: DOMDocumentType::$childNodes is NULL
Dom level 2 core, DOM level 3 core and the DOM living standard agree that `childNodes` always return a `NodeList`, and never `null`.
-rw-r--r--NEWS1
-rw-r--r--ext/dom/node.c10
-rw-r--r--ext/dom/tests/bug69846.phpt4
-rw-r--r--ext/dom/tests/bug79271.phpt17
4 files changed, 23 insertions, 9 deletions
diff --git a/NEWS b/NEWS
index f8f131a800..a80f373809 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,7 @@ PHP NEWS
- DOM:
. Fixed bug #77569: (Write Access Violation in DomImplementation). (Nikita,
cmb)
+ . Fixed bug #79271 (DOMDocumentType::$childNodes is NULL). (cmb)
- PCRE:
. Fixed bug #79188 (Memory corruption in preg_replace/preg_replace_callback
diff --git a/ext/dom/node.c b/ext/dom/node.c
index 0e7f64a9bd..7d939bcde1 100644
--- a/ext/dom/node.c
+++ b/ext/dom/node.c
@@ -428,13 +428,9 @@ int dom_node_child_nodes_read(dom_object *obj, zval *retval)
return FAILURE;
}
- if (dom_node_children_valid(nodep) == FAILURE) {
- ZVAL_NULL(retval);
- } else {
- php_dom_create_interator(retval, DOM_NODELIST);
- intern = Z_DOMOBJ_P(retval);
- dom_namednode_iter(obj, XML_ELEMENT_NODE, intern, NULL, NULL, NULL);
- }
+ php_dom_create_interator(retval, DOM_NODELIST);
+ intern = Z_DOMOBJ_P(retval);
+ dom_namednode_iter(obj, XML_ELEMENT_NODE, intern, NULL, NULL, NULL);
return SUCCESS;
}
diff --git a/ext/dom/tests/bug69846.phpt b/ext/dom/tests/bug69846.phpt
index fcca4c06d6..74662d53f6 100644
--- a/ext/dom/tests/bug69846.phpt
+++ b/ext/dom/tests/bug69846.phpt
@@ -50,7 +50,7 @@ object(DOMText)#%d (19) {
["parentNode"]=>
NULL
["childNodes"]=>
- NULL
+ string(22) "(object value omitted)"
["firstChild"]=>
NULL
["lastChild"]=>
@@ -140,7 +140,7 @@ object(DOMText)#%d (19) {
["parentNode"]=>
NULL
["childNodes"]=>
- NULL
+ string(22) "(object value omitted)"
["firstChild"]=>
NULL
["lastChild"]=>
diff --git a/ext/dom/tests/bug79271.phpt b/ext/dom/tests/bug79271.phpt
new file mode 100644
index 0000000000..c0ef07bd61
--- /dev/null
+++ b/ext/dom/tests/bug79271.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Bug #79271 (DOMDocumentType::$childNodes is NULL)
+--SKIPIF--
+<?php
+if (!extension_loaded('dom')) die('skip dom extension not available');
+?>
+--FILE--
+<?php
+$dom = new DOMImplementation();
+$type = $dom->createDocumentType('html');
+var_dump($type->childNodes);
+?>
+--EXPECTF--
+object(DOMNodeList)#%d (1) {
+ ["length"]=>
+ int(0)
+}