From d17ff9e2b2acca0bf836d3e3d9013cedb5a053d2 Mon Sep 17 00:00:00 2001 From: Levi Morrison Date: Fri, 22 Sep 2023 11:39:15 -0600 Subject: [PATCH] Set func pointer to null in Closure __invoke --- Zend/zend_closures.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c index 07eeb7c550452..f1b29af7967c9 100644 --- a/Zend/zend_closures.c +++ b/Zend/zend_closures.c @@ -58,9 +58,14 @@ ZEND_METHOD(Closure, __invoke) /* {{{ */ /* destruct the function also, then - we have allocated it in get_method */ zend_string_release_ex(func->internal_function.function_name, 0); efree(func); -#if ZEND_DEBUG + + /* Set the func pointer to NULL. Prior to PHP 8.3, this was only done for debug builds, + * because debug builds check certain properties after the call and needed to know this + * had been freed. + * However, extensions can proxy zend_execute_internal, and it's a bit surprising to have + * an invalid func pointer sitting on there, so this was changed in PHP 8.3. + */ execute_data->func = NULL; -#endif } /* }}} */