Skip to content

Commit

Permalink
IteratorIterator::getInnerIterator() can't return null
Browse files Browse the repository at this point in the history
If ther IteratorIterator is initialized (which we check), then
zobject cannot be undef and the return value cannot be null.
  • Loading branch information
nikic committed Jul 15, 2021
1 parent 282abfe commit c252420
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
10 changes: 3 additions & 7 deletions ext/spl/spl_iterators.c
Original file line number Diff line number Diff line change
Expand Up @@ -1447,13 +1447,9 @@ PHP_METHOD(IteratorIterator, getInnerIterator)

SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);

if (!Z_ISUNDEF(intern->inner.zobject)) {
zval *value = &intern->inner.zobject;

ZVAL_COPY_DEREF(return_value, value);
} else {
RETURN_NULL();
}
zval *value = &intern->inner.zobject;
ZEND_ASSERT(!Z_ISUNDEF_P(value));
ZVAL_COPY_DEREF(return_value, value);
} /* }}} */

static inline void spl_dual_it_free(spl_dual_it_object *intern)
Expand Down
2 changes: 1 addition & 1 deletion ext/spl/spl_iterators.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class IteratorIterator implements OuterIterator
{
public function __construct(Traversable $iterator, ?string $class = null) {}

/** @return Iterator|null */
/** @return Iterator */
public function getInnerIterator() {}

/** @return void */
Expand Down
2 changes: 1 addition & 1 deletion ext/spl/spl_iterators_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: de49628718b5fff1a3b2516cc89108e01b67c312 */
* Stub hash: d1cb33b7c3d1b480b68c6e52672a8ee2a3b382ef */

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_EmptyIterator_current, 0, 0, 0)
ZEND_END_ARG_INFO()
Expand Down

0 comments on commit c252420

Please sign in to comment.