mirror of
https://github.com/php/php-src.git
synced 2024-11-24 10:24:11 +08:00
Fixed memory leak
This commit is contained in:
parent
0604df8a82
commit
fc75d07652
9
Zend/tests/generators/generator_closure_unused.phpt
Normal file
9
Zend/tests/generators/generator_closure_unused.phpt
Normal file
@ -0,0 +1,9 @@
|
||||
--TEST--
|
||||
Closures can be unused generators
|
||||
--FILE--
|
||||
<?php
|
||||
(function(){yield;})();
|
||||
echo "ok\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
ok
|
@ -3563,7 +3563,7 @@ ZEND_VM_HANDLER(131, ZEND_DO_FCALL_BY_NAME, ANY, ANY)
|
||||
if (EXPECTED(fbc->type == ZEND_USER_FUNCTION)) {
|
||||
EG(scope) = NULL;
|
||||
if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_GENERATOR) != 0)) {
|
||||
if (RETURN_VALUE_USED(opline)) {
|
||||
if (EXPECTED(RETURN_VALUE_USED(opline))) {
|
||||
ret = EX_VAR(opline->result.var);
|
||||
zend_generator_create_zval(call, &fbc->op_array, ret);
|
||||
Z_VAR_FLAGS_P(ret) = 0;
|
||||
@ -3685,11 +3685,14 @@ ZEND_VM_HANDLER(60, ZEND_DO_FCALL, ANY, ANY)
|
||||
if (EXPECTED(fbc->type == ZEND_USER_FUNCTION)) {
|
||||
EG(scope) = fbc->common.scope;
|
||||
if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_GENERATOR) != 0)) {
|
||||
if (RETURN_VALUE_USED(opline)) {
|
||||
if (EXPECTED(RETURN_VALUE_USED(opline))) {
|
||||
ret = EX_VAR(opline->result.var);
|
||||
zend_generator_create_zval(call, &fbc->op_array, ret);
|
||||
Z_VAR_FLAGS_P(ret) = 0;
|
||||
} else {
|
||||
if (UNEXPECTED(ZEND_CALL_INFO(call) & ZEND_CALL_CLOSURE)) {
|
||||
OBJ_RELEASE((zend_object*)fbc->op_array.prototype);
|
||||
}
|
||||
zend_vm_stack_free_args(call);
|
||||
}
|
||||
} else {
|
||||
|
@ -627,7 +627,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_DO_FCALL_BY_NAME_SPEC_HANDLER(
|
||||
if (EXPECTED(fbc->type == ZEND_USER_FUNCTION)) {
|
||||
EG(scope) = NULL;
|
||||
if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_GENERATOR) != 0)) {
|
||||
if (RETURN_VALUE_USED(opline)) {
|
||||
if (EXPECTED(RETURN_VALUE_USED(opline))) {
|
||||
ret = EX_VAR(opline->result.var);
|
||||
zend_generator_create_zval(call, &fbc->op_array, ret);
|
||||
Z_VAR_FLAGS_P(ret) = 0;
|
||||
@ -749,11 +749,14 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_DO_FCALL_SPEC_HANDLER(ZEND_OPC
|
||||
if (EXPECTED(fbc->type == ZEND_USER_FUNCTION)) {
|
||||
EG(scope) = fbc->common.scope;
|
||||
if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_GENERATOR) != 0)) {
|
||||
if (RETURN_VALUE_USED(opline)) {
|
||||
if (EXPECTED(RETURN_VALUE_USED(opline))) {
|
||||
ret = EX_VAR(opline->result.var);
|
||||
zend_generator_create_zval(call, &fbc->op_array, ret);
|
||||
Z_VAR_FLAGS_P(ret) = 0;
|
||||
} else {
|
||||
if (UNEXPECTED(ZEND_CALL_INFO(call) & ZEND_CALL_CLOSURE)) {
|
||||
OBJ_RELEASE((zend_object*)fbc->op_array.prototype);
|
||||
}
|
||||
zend_vm_stack_free_args(call);
|
||||
}
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user