Skip to content

Commit a12fe30

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
2 parents 4355140 + 34edd4a commit a12fe30

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

Zend/tests/closure_extra_args.phpt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
Immediately invoked closure with extra args
3+
--FILE--
4+
<?php
5+
6+
(function() {})(new stdClass);
7+
8+
?>
9+
===DONE===
10+
--EXPECT--
11+
===DONE===

Zend/zend_vm_def.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2909,13 +2909,17 @@ ZEND_VM_HOT_HELPER(zend_leave_helper, ANY, ANY)
29092909
zend_clean_and_cache_symbol_table(EX(symbol_table));
29102910
}
29112911
EG(current_execute_data) = EX(prev_execute_data);
2912+
2913+
/* Free extra args before releasing the closure,
2914+
* as that may free the op_array. */
2915+
zend_vm_stack_free_extra_args_ex(call_info, execute_data);
2916+
29122917
if (UNEXPECTED(call_info & ZEND_CALL_RELEASE_THIS)) {
29132918
OBJ_RELEASE(Z_OBJ(execute_data->This));
29142919
} else if (UNEXPECTED(call_info & ZEND_CALL_CLOSURE)) {
29152920
OBJ_RELEASE(ZEND_CLOSURE_OBJECT(EX(func)));
29162921
}
29172922

2918-
zend_vm_stack_free_extra_args_ex(call_info, execute_data);
29192923
old_execute_data = execute_data;
29202924
execute_data = EX(prev_execute_data);
29212925
zend_vm_stack_free_call_frame_ex(call_info, old_execute_data);

Zend/zend_vm_execute.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,13 +1173,17 @@ static zend_never_inline ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_leave_helper
11731173
zend_clean_and_cache_symbol_table(EX(symbol_table));
11741174
}
11751175
EG(current_execute_data) = EX(prev_execute_data);
1176+
1177+
/* Free extra args before releasing the closure,
1178+
* as that may free the op_array. */
1179+
zend_vm_stack_free_extra_args_ex(call_info, execute_data);
1180+
11761181
if (UNEXPECTED(call_info & ZEND_CALL_RELEASE_THIS)) {
11771182
OBJ_RELEASE(Z_OBJ(execute_data->This));
11781183
} else if (UNEXPECTED(call_info & ZEND_CALL_CLOSURE)) {
11791184
OBJ_RELEASE(ZEND_CLOSURE_OBJECT(EX(func)));
11801185
}
11811186

1182-
zend_vm_stack_free_extra_args_ex(call_info, execute_data);
11831187
old_execute_data = execute_data;
11841188
execute_data = EX(prev_execute_data);
11851189
zend_vm_stack_free_call_frame_ex(call_info, old_execute_data);
@@ -53366,13 +53370,17 @@ ZEND_API void execute_ex(zend_execute_data *ex)
5336653370
zend_clean_and_cache_symbol_table(EX(symbol_table));
5336753371
}
5336853372
EG(current_execute_data) = EX(prev_execute_data);
53373+
53374+
/* Free extra args before releasing the closure,
53375+
* as that may free the op_array. */
53376+
zend_vm_stack_free_extra_args_ex(call_info, execute_data);
53377+
5336953378
if (UNEXPECTED(call_info & ZEND_CALL_RELEASE_THIS)) {
5337053379
OBJ_RELEASE(Z_OBJ(execute_data->This));
5337153380
} else if (UNEXPECTED(call_info & ZEND_CALL_CLOSURE)) {
5337253381
OBJ_RELEASE(ZEND_CLOSURE_OBJECT(EX(func)));
5337353382
}
5337453383

53375-
zend_vm_stack_free_extra_args_ex(call_info, execute_data);
5337653384
old_execute_data = execute_data;
5337753385
execute_data = EX(prev_execute_data);
5337853386
zend_vm_stack_free_call_frame_ex(call_info, old_execute_data);

0 commit comments

Comments
 (0)