Skip to content

Commit fcabe7e

Browse files
committed
Fixed bug #78412
$this should only be included in the generator GC buffer, if it will be released on destruction.
1 parent 4b64d47 commit fcabe7e

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? 2019, PHP 7.2.23
44

5+
- Core:
6+
. Fixed bug #78412 (Generator incorrectly reports non-releasable $this as GC
7+
child). (Nikita)
8+
59
29 Aug 2019, PHP 7.2.22
610

711
- Core:

Zend/zend_generators.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ static uint32_t calc_gc_buffer_size(zend_generator *generator) /* {{{ */
271271
if (EX_CALL_INFO() & ZEND_CALL_FREE_EXTRA_ARGS) {
272272
size += EX_NUM_ARGS() - op_array->num_args;
273273
}
274-
size += Z_TYPE(execute_data->This) == IS_OBJECT; /* $this */
274+
size += (EX_CALL_INFO() & ZEND_CALL_RELEASE_THIS) != 0; /* $this */
275275
size += (EX_CALL_INFO() & ZEND_CALL_CLOSURE) != 0; /* Closure object */
276276

277277
/* Live vars */
@@ -352,7 +352,7 @@ static HashTable *zend_generator_get_gc(zval *object, zval **table, int *n) /* {
352352
}
353353
}
354354

355-
if (Z_TYPE(execute_data->This) == IS_OBJECT) {
355+
if (EX_CALL_INFO() & ZEND_CALL_RELEASE_THIS) {
356356
ZVAL_OBJ(gc_buffer++, Z_OBJ(execute_data->This));
357357
}
358358
if (EX_CALL_INFO() & ZEND_CALL_CLOSURE) {

0 commit comments

Comments
 (0)