Skip to content

Commit c252420

Browse files
committed
IteratorIterator::getInnerIterator() can't return null
If ther IteratorIterator is initialized (which we check), then zobject cannot be undef and the return value cannot be null.
1 parent 282abfe commit c252420

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed

ext/spl/spl_iterators.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,13 +1447,9 @@ PHP_METHOD(IteratorIterator, getInnerIterator)
14471447

14481448
SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
14491449

1450-
if (!Z_ISUNDEF(intern->inner.zobject)) {
1451-
zval *value = &intern->inner.zobject;
1452-
1453-
ZVAL_COPY_DEREF(return_value, value);
1454-
} else {
1455-
RETURN_NULL();
1456-
}
1450+
zval *value = &intern->inner.zobject;
1451+
ZEND_ASSERT(!Z_ISUNDEF_P(value));
1452+
ZVAL_COPY_DEREF(return_value, value);
14571453
} /* }}} */
14581454

14591455
static inline void spl_dual_it_free(spl_dual_it_object *intern)

ext/spl/spl_iterators.stub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class IteratorIterator implements OuterIterator
117117
{
118118
public function __construct(Traversable $iterator, ?string $class = null) {}
119119

120-
/** @return Iterator|null */
120+
/** @return Iterator */
121121
public function getInnerIterator() {}
122122

123123
/** @return void */

ext/spl/spl_iterators_arginfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: de49628718b5fff1a3b2516cc89108e01b67c312 */
2+
* Stub hash: d1cb33b7c3d1b480b68c6e52672a8ee2a3b382ef */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_EmptyIterator_current, 0, 0, 0)
55
ZEND_END_ARG_INFO()

0 commit comments

Comments
 (0)