Fix leaks in yield from error conditions

Conflicts:
	Zend/zend_vm_execute.h
This commit is contained in:
Nikita Popov 2016-07-14 15:55:30 +02:00
parent d1f82bfeb2
commit c3804a2cf9
2 changed files with 10 additions and 0 deletions

View File

@ -7469,12 +7469,14 @@ ZEND_VM_HANDLER(142, ZEND_YIELD_FROM, CONST|TMP|VAR|CV, ANY)
if (Z_ISUNDEF(new_gen->retval)) {
if (UNEXPECTED(zend_generator_get_current(new_gen) == generator)) {
zend_throw_error(NULL, "Impossible to yield from the Generator being currently run");
zval_ptr_dtor(val);
HANDLE_EXCEPTION();
} else {
zend_generator_yield_from(generator, new_gen);
}
} else if (UNEXPECTED(new_gen->execute_data == NULL)) {
zend_throw_error(NULL, "Generator passed to yield from was aborted without proper return and is unable to continue");
zval_ptr_dtor(val);
HANDLE_EXCEPTION();
} else {
if (RETURN_VALUE_USED(opline)) {

View File

@ -4135,12 +4135,14 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_YIELD_FROM_SPEC_CONST_HANDLER(
if (Z_ISUNDEF(new_gen->retval)) {
if (UNEXPECTED(zend_generator_get_current(new_gen) == generator)) {
zend_throw_error(NULL, "Impossible to yield from the Generator being currently run");
zval_ptr_dtor(val);
HANDLE_EXCEPTION();
} else {
zend_generator_yield_from(generator, new_gen);
}
} else if (UNEXPECTED(new_gen->execute_data == NULL)) {
zend_throw_error(NULL, "Generator passed to yield from was aborted without proper return and is unable to continue");
zval_ptr_dtor(val);
HANDLE_EXCEPTION();
} else {
if (RETURN_VALUE_USED(opline)) {
@ -12537,12 +12539,14 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_YIELD_FROM_SPEC_TMP_HANDLER(ZE
if (Z_ISUNDEF(new_gen->retval)) {
if (UNEXPECTED(zend_generator_get_current(new_gen) == generator)) {
zend_throw_error(NULL, "Impossible to yield from the Generator being currently run");
zval_ptr_dtor(val);
HANDLE_EXCEPTION();
} else {
zend_generator_yield_from(generator, new_gen);
}
} else if (UNEXPECTED(new_gen->execute_data == NULL)) {
zend_throw_error(NULL, "Generator passed to yield from was aborted without proper return and is unable to continue");
zval_ptr_dtor(val);
HANDLE_EXCEPTION();
} else {
if (RETURN_VALUE_USED(opline)) {
@ -16358,12 +16362,14 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_YIELD_FROM_SPEC_VAR_HANDLER(ZE
if (Z_ISUNDEF(new_gen->retval)) {
if (UNEXPECTED(zend_generator_get_current(new_gen) == generator)) {
zend_throw_error(NULL, "Impossible to yield from the Generator being currently run");
zval_ptr_dtor(val);
HANDLE_EXCEPTION();
} else {
zend_generator_yield_from(generator, new_gen);
}
} else if (UNEXPECTED(new_gen->execute_data == NULL)) {
zend_throw_error(NULL, "Generator passed to yield from was aborted without proper return and is unable to continue");
zval_ptr_dtor(val);
HANDLE_EXCEPTION();
} else {
if (RETURN_VALUE_USED(opline)) {
@ -29802,12 +29808,14 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_YIELD_FROM_SPEC_CV_HANDLER(ZEN
if (Z_ISUNDEF(new_gen->retval)) {
if (UNEXPECTED(zend_generator_get_current(new_gen) == generator)) {
zend_throw_error(NULL, "Impossible to yield from the Generator being currently run");
zval_ptr_dtor(val);
HANDLE_EXCEPTION();
} else {
zend_generator_yield_from(generator, new_gen);
}
} else if (UNEXPECTED(new_gen->execute_data == NULL)) {
zend_throw_error(NULL, "Generator passed to yield from was aborted without proper return and is unable to continue");
zval_ptr_dtor(val);
HANDLE_EXCEPTION();
} else {
if (RETURN_VALUE_USED(opline)) {