Skip to content

Commit 0c99661

Browse files
committed
Fixed bug #62616 (ArrayIterator::count() from IteratorIterator instance gives Segmentation fault)
1 parent a6f1533 commit 0c99661

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ PHP NEWS
3232
. Implemented FR #55218 Get namespaces from current node. (Lonny)
3333

3434
- SPL:
35+
. Fixed bug #62616 (ArrayIterator::count() from IteratorIterator instance
36+
gives Segmentation fault). (Laruence, Gustavo)
3537
. Fixed bug #61527 (ArrayIterator gives misleading notice on next() when
3638
moved to the end). ([email protected])
3739

ext/spl/spl_iterators.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,6 +1289,8 @@ static union _zend_function *spl_dual_it_get_method(zval **object_ptr, char *met
12891289
*object_ptr = intern->inner.zobject;
12901290
function_handler = Z_OBJ_HT_P(*object_ptr)->get_method(object_ptr, method, method_len, key TSRMLS_CC);
12911291
}
1292+
} else {
1293+
*object_ptr = intern->inner.zobject;
12921294
}
12931295
}
12941296
return function_handler;

ext/spl/tests/bug62616.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Bug #62616 (ArrayIterator::count() from IteratorIterator instance gives Segmentation fault)
3+
--FILE--
4+
<?php
5+
$ai = new ArrayIterator(array(0,1));
6+
7+
var_dump($ai->count());
8+
9+
$ii = new IteratorIterator($ai);
10+
11+
var_dump($ii->count());
12+
?>
13+
--EXPECTF--
14+
int(2)
15+
int(2)

0 commit comments

Comments
 (0)