Skip to content

Commit

Permalink
Fix emory leak
Browse files Browse the repository at this point in the history
Fixes oss-fuzz #44408
  • Loading branch information
dstogov committed Feb 11, 2022
1 parent a506b00 commit 73fed0f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
12 changes: 12 additions & 0 deletions Zend/tests/closure_063.phpt
@@ -0,0 +1,12 @@
--TEST--
Closure::bindTo leaks with "fake" closure
--FILE--
<?php
function foo(){
static $y;
}
Closure::fromCallable('foo')->bindTo(new stdClass);
?>
DONE
--EXPECT--
DONE
3 changes: 2 additions & 1 deletion Zend/zend_closures.c
Expand Up @@ -770,7 +770,8 @@ static void zend_create_closure_ex(zval *res, zend_function *func, zend_class_en

ZEND_API void zend_create_closure(zval *res, zend_function *func, zend_class_entry *scope, zend_class_entry *called_scope, zval *this_ptr)
{
zend_create_closure_ex(res, func, scope, called_scope, this_ptr, /* is_fake */ false);
zend_create_closure_ex(res, func, scope, called_scope, this_ptr,
/* is_fake */ (func->common.fn_flags & ZEND_ACC_FAKE_CLOSURE) != 0);
}

ZEND_API void zend_create_fake_closure(zval *res, zend_function *func, zend_class_entry *scope, zend_class_entry *called_scope, zval *this_ptr) /* {{{ */
Expand Down

0 comments on commit 73fed0f

Please sign in to comment.