Skip to content

Commit 2306ca7

Browse files
committed
Share static_variables table for fake closures
1 parent 898312a commit 2306ca7

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Zend/zend_closures.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,14 @@ static void zend_create_closure_ex(zval *res, zend_function *func, zend_class_en
689689
}
690690
ZEND_MAP_PTR_INIT(closure->func.op_array.static_variables_ptr,
691691
closure->func.op_array.static_variables);
692+
} else if (func->op_array.static_variables) {
693+
HashTable *ht = ZEND_MAP_PTR_GET(func->op_array.static_variables_ptr);
694+
695+
if (!ht) {
696+
ht = zend_array_dup(func->op_array.static_variables);
697+
ZEND_MAP_PTR_SET(func->op_array.static_variables_ptr, ht);
698+
}
699+
ZEND_MAP_PTR_INIT(closure->func.op_array.static_variables_ptr, ht);
692700
}
693701

694702
/* Runtime cache is scope-dependent, so we cannot reuse it if the scope changed */

0 commit comments

Comments
 (0)