From a41723d0f42d2511a6f8df75ab2e7ce1fa85a156 Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Sun, 13 Aug 2006 15:03:19 +0000 Subject: [PATCH] MFB: Fixed bug #38438 (DOMNodeList->item(0) segfault on empty NodeList) --- ext/dom/nodelist.c | 2 +- ext/dom/tests/bug38438.phpt | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 ext/dom/tests/bug38438.phpt diff --git a/ext/dom/nodelist.c b/ext/dom/nodelist.c index 8989f907ad9..268879bc165 100644 --- a/ext/dom/nodelist.c +++ b/ext/dom/nodelist.c @@ -134,7 +134,7 @@ PHP_FUNCTION(dom_nodelist_item) zval_copy_ctor(return_value); return; } - } else { + } else if (objmap->baseobj) { nodep = dom_object_get_node(objmap->baseobj); if (nodep) { if (objmap->nodetype == XML_ATTRIBUTE_NODE || objmap->nodetype == XML_ELEMENT_NODE) { diff --git a/ext/dom/tests/bug38438.phpt b/ext/dom/tests/bug38438.phpt new file mode 100644 index 00000000000..f51252832c6 --- /dev/null +++ b/ext/dom/tests/bug38438.phpt @@ -0,0 +1,13 @@ +--TEST-- +Bug #38438 (DOMNodeList->item(0) segfault on empty NodeList) +--SKIPIF-- + +--FILE-- +item(0)); +echo "OK\n"; +?> +--EXPECT-- +NULL +OK