Skip to content

Commit 8a00faa

Browse files
committed
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2: Fix GH-15551: Segmentation fault (access null pointer) in ext/dom/xml_common.h
2 parents 70c5e36 + 9af574c commit 8a00faa

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

NEWS

+4
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

+4-2
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,15 @@ static void php_dom_iterator_move_forward(zend_object_iterator *iter) /* {{{ */
185185
bool do_curobj_undef = 1;
186186

187187
php_dom_iterator *iterator = (php_dom_iterator *)iter;
188+
if (Z_ISUNDEF(iterator->curobj)) {
189+
return;
190+
}
188191

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

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

ext/dom/tests/gh15551.phpt

+14
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)