Skip to content

Commit 73fed0f

Browse files
committed
Fix emory leak
Fixes oss-fuzz #44408
1 parent a506b00 commit 73fed0f

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

Zend/tests/closure_063.phpt

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
Closure::bindTo leaks with "fake" closure
3+
--FILE--
4+
<?php
5+
function foo(){
6+
static $y;
7+
}
8+
Closure::fromCallable('foo')->bindTo(new stdClass);
9+
?>
10+
DONE
11+
--EXPECT--
12+
DONE

Zend/zend_closures.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,8 @@ static void zend_create_closure_ex(zval *res, zend_function *func, zend_class_en
770770

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

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

0 commit comments

Comments
 (0)