Skip to content

Commit 988c3f9

Browse files
committed
Fix memleak on ReflectionFunction and ReflectionGenerator classes when calling __construct after instantiation
1 parent ae0585c commit 988c3f9

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

ext/reflection/php_reflection.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1534,6 +1534,11 @@ ZEND_METHOD(reflection_function, __construct)
15341534
}
15351535
}
15361536

1537+
if (intern->ptr) {
1538+
zval_ptr_dtor(&intern->obj);
1539+
zval_ptr_dtor(reflection_prop_name(object));
1540+
}
1541+
15371542
ZVAL_STR_COPY(reflection_prop_name(object), fptr->common.function_name);
15381543
intern->ptr = fptr;
15391544
intern->ref_type = REF_TYPE_FUNCTION;
@@ -2073,6 +2078,10 @@ ZEND_METHOD(reflection_generator, __construct)
20732078
return;
20742079
}
20752080

2081+
if (intern->ce) {
2082+
zval_ptr_dtor(&intern->obj);
2083+
}
2084+
20762085
intern->ref_type = REF_TYPE_GENERATOR;
20772086
Z_ADDREF_P(generator);
20782087
ZVAL_OBJ(&intern->obj, Z_OBJ_P(generator));

0 commit comments

Comments
 (0)