File tree 3 files changed +28
-2
lines changed 3 files changed +28
-2
lines changed Original file line number Diff line number Diff line change 6
6
. Fix crashes when entity declaration is removed while still having entity
7
7
references. (nielsdos)
8
8
. Fix references not handled correctly in C14N. (nielsdos)
9
+ . Fix crash when calling childNodes next() when iterator is exhausted.
10
+ (nielsdos)
9
11
10
12
09 May 2024, PHP 8.2.19
11
13
Original file line number Diff line number Diff line change @@ -147,8 +147,7 @@ static int php_dom_iterator_valid(zend_object_iterator *iter) /* {{{ */
147
147
zval * php_dom_iterator_current_data (zend_object_iterator * iter ) /* {{{ */
148
148
{
149
149
php_dom_iterator * iterator = (php_dom_iterator * )iter ;
150
-
151
- return & iterator -> curobj ;
150
+ return Z_ISUNDEF (iterator -> curobj ) ? NULL : & iterator -> curobj ;
152
151
}
153
152
/* }}} */
154
153
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Crash in childNodes iterator current()
3
+ --EXTENSIONS--
4
+ dom
5
+ --FILE--
6
+ <?php
7
+
8
+ $ dom = new DOMDocument ;
9
+ $ dom ->loadXML ('<foo>foo1</foo> ' );
10
+
11
+ $ nodes = $ dom ->documentElement ->childNodes ;
12
+ $ iter = $ nodes ->getIterator ();
13
+
14
+ var_dump ($ iter ->valid ());
15
+ var_dump ($ iter ->current ()?->wholeText);
16
+ $ iter ->next ();
17
+ var_dump ($ iter ->valid ());
18
+ var_dump ($ iter ->current ()?->wholeText);
19
+
20
+ ?>
21
+ --EXPECT--
22
+ bool(true)
23
+ string(4) "foo1"
24
+ bool(false)
25
+ NULL
You can’t perform that action at this time.
0 commit comments