Skip to content

Commit

Permalink
Delay releasing closures until after observer end
Browse files Browse the repository at this point in the history
  • Loading branch information
bwoebi committed Nov 2, 2022
1 parent 4935e10 commit 8e49d7f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 3 additions & 1 deletion Zend/zend_closures.c
Expand Up @@ -695,7 +695,9 @@ static ZEND_NAMED_FUNCTION(zend_closure_internal_handler) /* {{{ */
{
zend_closure *closure = (zend_closure*)ZEND_CLOSURE_OBJECT(EX(func));
closure->orig_internal_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU);
OBJ_RELEASE((zend_object*)closure);
// Assign to EX(this) so that it is released after observer checks etc.
ZEND_ADD_CALL_FLAG(execute_data, ZEND_CALL_RELEASE_THIS);
Z_OBJ(EX(This)) = &closure->std;
}
/* }}} */

Expand Down
4 changes: 1 addition & 3 deletions ext/zend_test/tests/observer_closure_03.phpt
Expand Up @@ -7,9 +7,7 @@ zend_test.observer.enabled=1
zend_test.observer.observe_all=1
--FILE--
<?php
$closure = strlen(...);
var_dump($closure('test'));

var_dump(strlen(...)('test'));
echo 'DONE' . PHP_EOL;
?>
--EXPECTF--
Expand Down

0 comments on commit 8e49d7f

Please sign in to comment.