Skip to content

Zend/zend_execute: clear reference before calling dtor #10556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Zend/zend_execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -3554,6 +3554,13 @@ static zend_always_inline void i_zval_ptr_dtor_noref(zval *zval_ptr) {
if (Z_REFCOUNTED_P(zval_ptr)) {
zend_refcounted *ref = Z_COUNTED_P(zval_ptr);
ZEND_ASSERT(Z_TYPE_P(zval_ptr) != IS_REFERENCE);

/* clear reference before invoking the destructor, or
else something inside the destructor may assign the
reference again, triggering another recursive
destructor call */
ZVAL_UNDEF(zval_ptr);

if (!GC_DELREF(ref)) {
rc_dtor_func(ref);
} else if (UNEXPECTED(GC_MAY_LEAK(ref))) {
Expand Down