Merge branch 'PHP-7.4'

* PHP-7.4:
  Fix memory leak when yielding from non-iterable
This commit is contained in:
Nikita Popov 2020-08-26 11:32:56 +02:00
commit d7d2b060e1
3 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,18 @@
--TEST--
Yield from non-iterable
--FILE--
<?php
function gen() {
yield from new stdClass;
}
try {
gen()->current();
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECT--
Can use "yield from" only with arrays and Traversables

View File

@ -8067,6 +8067,7 @@ ZEND_VM_C_LABEL(yield_from_try_again):
ZEND_VM_C_GOTO(yield_from_try_again);
} else {
zend_throw_error(NULL, "Can use \"yield from\" only with arrays and Traversables");
FREE_OP1();
UNDEF_RESULT();
HANDLE_EXCEPTION();
}

View File

@ -4545,6 +4545,7 @@ yield_from_try_again:
goto yield_from_try_again;
} else {
zend_throw_error(NULL, "Can use \"yield from\" only with arrays and Traversables");
UNDEF_RESULT();
HANDLE_EXCEPTION();
}
@ -13707,6 +13708,7 @@ yield_from_try_again:
goto yield_from_try_again;
} else {
zend_throw_error(NULL, "Can use \"yield from\" only with arrays and Traversables");
zval_ptr_dtor_nogc(EX_VAR(opline->op1.var));
UNDEF_RESULT();
HANDLE_EXCEPTION();
}
@ -37728,6 +37730,7 @@ yield_from_try_again:
goto yield_from_try_again;
} else {
zend_throw_error(NULL, "Can use \"yield from\" only with arrays and Traversables");
UNDEF_RESULT();
HANDLE_EXCEPTION();
}