Skip to content

Commit 9af574c

Browse files
committed
Fix GH-15551: Segmentation fault (access null pointer) in ext/dom/xml_common.h
Closes GH-15556.
1 parent 48a18e5 commit 9af574c

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ PHP NEWS
88
. Fixed bug GH-15515 (Configure error grep illegal option q). (Peter Kokot)
99
. Fixed bug GH-15514 (Configure error: genif.sh: syntax error). (Peter Kokot)
1010

11+
- DOM:
12+
. Fixed bug GH-15551 (Segmentation fault (access null pointer) in
13+
ext/dom/xml_common.h). (nielsdos)
14+
1115
- MySQLnd:
1216
. Fixed bug GH-15432 (Heap corruption when querying a vector). (cmb,
1317
Kamil Tekiela)

ext/dom/dom_iterators.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,15 @@ static void php_dom_iterator_move_forward(zend_object_iterator *iter) /* {{{ */
184184
bool do_curobj_undef = 1;
185185

186186
php_dom_iterator *iterator = (php_dom_iterator *)iter;
187+
if (Z_ISUNDEF(iterator->curobj)) {
188+
return;
189+
}
187190

191+
intern = Z_DOMOBJ_P(&iterator->curobj);
188192
object = &iterator->intern.data;
189193
nnmap = Z_DOMOBJ_P(object);
190194
objmap = (dom_nnodemap_object *)nnmap->ptr;
191195

192-
intern = Z_DOMOBJ_P(&iterator->curobj);
193-
194196
if (intern != NULL && intern->ptr != NULL) {
195197
if (objmap->nodetype != XML_ENTITY_NODE &&
196198
objmap->nodetype != XML_NOTATION_NODE) {

ext/dom/tests/gh15551.phpt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
GH-15551 (Segmentation fault (access null pointer) in ext/dom/xml_common.h)
3+
--EXTENSIONS--
4+
dom
5+
--FILE--
6+
<?php
7+
$fragment = new DOMDocumentFragment();
8+
$nodes = $fragment->childNodes;
9+
$iter = $nodes->getIterator();
10+
$iter->next();
11+
var_dump($iter->valid());
12+
?>
13+
--EXPECT--
14+
bool(false)

0 commit comments

Comments
 (0)