Skip to content

Commit

Permalink
Fixed bug #78412
Browse files Browse the repository at this point in the history
$this should only be included in the generator GC buffer, if it
will be released on destruction.
  • Loading branch information
nikic committed Aug 14, 2019
1 parent 4b64d47 commit fcabe7e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2019, PHP 7.2.23

- Core:
. Fixed bug #78412 (Generator incorrectly reports non-releasable $this as GC
child). (Nikita)

29 Aug 2019, PHP 7.2.22

- Core:
Expand Down
4 changes: 2 additions & 2 deletions Zend/zend_generators.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ static uint32_t calc_gc_buffer_size(zend_generator *generator) /* {{{ */
if (EX_CALL_INFO() & ZEND_CALL_FREE_EXTRA_ARGS) {
size += EX_NUM_ARGS() - op_array->num_args;
}
size += Z_TYPE(execute_data->This) == IS_OBJECT; /* $this */
size += (EX_CALL_INFO() & ZEND_CALL_RELEASE_THIS) != 0; /* $this */
size += (EX_CALL_INFO() & ZEND_CALL_CLOSURE) != 0; /* Closure object */

/* Live vars */
Expand Down Expand Up @@ -352,7 +352,7 @@ static HashTable *zend_generator_get_gc(zval *object, zval **table, int *n) /* {
}
}

if (Z_TYPE(execute_data->This) == IS_OBJECT) {
if (EX_CALL_INFO() & ZEND_CALL_RELEASE_THIS) {
ZVAL_OBJ(gc_buffer++, Z_OBJ(execute_data->This));
}
if (EX_CALL_INFO() & ZEND_CALL_CLOSURE) {
Expand Down

0 comments on commit fcabe7e

Please sign in to comment.