Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Zend/tests/lazy_objects/gh20085.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
--TEST--
GH-20085 (Assertion failure when combining lazy object get_properties exception with foreach loop)
--FILE--
<?php
class C {
public int $a;
public function __construct() {
$this->a = 1;
}
}
$obj = new C;
$reflector = new ReflectionClass(C::class);
foreach ($obj as &$value) {
$obj = $reflector->newLazyGhost(function ($obj) {
throw new Error;
});
}
echo !obj;
?>
--EXPECTF--
Fatal error: Uncaught Error in %s:%d
Stack trace:
#0 %s(%d): {closure:%s:%d}(Object(C))
#1 {main}
thrown in %s on line %d
3 changes: 2 additions & 1 deletion Zend/zend_vm_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -7275,7 +7275,7 @@ ZEND_VM_HANDLER(126, ZEND_FE_FETCH_RW, VAR, ANY, JMP_ADDR)
while (1) {
if (UNEXPECTED(pos >= fe_ht->nNumUsed)) {
/* reached end of iteration */
ZEND_VM_C_GOTO(fe_fetch_w_exit);
ZEND_VM_C_GOTO(fe_fetch_w_exit_exc);
}
pos++;
value = &p->val;
Expand Down Expand Up @@ -7371,6 +7371,7 @@ ZEND_VM_HANDLER(126, ZEND_FE_FETCH_RW, VAR, ANY, JMP_ADDR)
}
} else {
zend_error(E_WARNING, "foreach() argument must be of type array|object, %s given", zend_zval_value_name(array));
ZEND_VM_C_LABEL(fe_fetch_w_exit_exc):
if (UNEXPECTED(EG(exception))) {
UNDEF_RESULT();
HANDLE_EXCEPTION();
Expand Down
3 changes: 2 additions & 1 deletion Zend/zend_vm_execute.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.