Skip to content

Commit a1e0936

Browse files
committed
Merge branch 'PHP-8.1'
* PHP-8.1: Fix emory leak
2 parents 02952d3 + 73fed0f commit a1e0936

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
@@ -775,7 +775,8 @@ static void zend_create_closure_ex(zval *res, zend_function *func, zend_class_en
775775

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

781782
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)