diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2019-08-29 12:32:23 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-08-29 12:33:04 +0200 |
commit | 34edd4aa2aa100a39075d3c4b086165f8c372945 (patch) | |
tree | ab4620b8b21da8f729337ad5ffc7ed4933456401 | |
parent | 195b8ae7791c9f556cd26ceb5f5d6eca91ac47ca (diff) | |
parent | ed749edd477bfcc3923c086a6443aaa91192e5b7 (diff) | |
download | php-git-34edd4aa2aa100a39075d3c4b086165f8c372945.tar.gz |
Merge branch 'PHP-7.2' into PHP-7.3
-rw-r--r-- | Zend/tests/closure_extra_args.phpt | 11 | ||||
-rw-r--r-- | Zend/zend_vm_def.h | 6 | ||||
-rw-r--r-- | Zend/zend_vm_execute.h | 12 |
3 files changed, 26 insertions, 3 deletions
diff --git a/Zend/tests/closure_extra_args.phpt b/Zend/tests/closure_extra_args.phpt new file mode 100644 index 0000000000..05712e06c6 --- /dev/null +++ b/Zend/tests/closure_extra_args.phpt @@ -0,0 +1,11 @@ +--TEST-- +Immediately invoked closure with extra args +--FILE-- +<?php + +(function() {})(new stdClass); + +?> +===DONE=== +--EXPECT-- +===DONE=== diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 0bedf907a2..99b731b11a 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -2430,6 +2430,11 @@ ZEND_VM_HOT_HELPER(zend_leave_helper, ANY, ANY) zend_clean_and_cache_symbol_table(EX(symbol_table)); } EG(current_execute_data) = EX(prev_execute_data); + + /* Free extra args before releasing the closure, + * as that may free the op_array. */ + zend_vm_stack_free_extra_args_ex(call_info, execute_data); + if (UNEXPECTED(call_info & ZEND_CALL_RELEASE_THIS)) { zend_object *object = Z_OBJ(execute_data->This); #if 0 @@ -2445,7 +2450,6 @@ ZEND_VM_HOT_HELPER(zend_leave_helper, ANY, ANY) OBJ_RELEASE(ZEND_CLOSURE_OBJECT(EX(func))); } - zend_vm_stack_free_extra_args_ex(call_info, execute_data); old_execute_data = execute_data; execute_data = EX(prev_execute_data); zend_vm_stack_free_call_frame_ex(call_info, old_execute_data); diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 1c95ac57a0..b29f5bddc6 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -541,6 +541,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_leave_helper_SPEC(ZEND_OPCODE_ zend_clean_and_cache_symbol_table(EX(symbol_table)); } EG(current_execute_data) = EX(prev_execute_data); + + /* Free extra args before releasing the closure, + * as that may free the op_array. */ + zend_vm_stack_free_extra_args_ex(call_info, execute_data); + if (UNEXPECTED(call_info & ZEND_CALL_RELEASE_THIS)) { zend_object *object = Z_OBJ(execute_data->This); #if 0 @@ -556,7 +561,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_leave_helper_SPEC(ZEND_OPCODE_ OBJ_RELEASE(ZEND_CLOSURE_OBJECT(EX(func))); } - zend_vm_stack_free_extra_args_ex(call_info, execute_data); old_execute_data = execute_data; execute_data = EX(prev_execute_data); zend_vm_stack_free_call_frame_ex(call_info, old_execute_data); @@ -55375,6 +55379,11 @@ zend_leave_helper_SPEC_LABEL: zend_clean_and_cache_symbol_table(EX(symbol_table)); } EG(current_execute_data) = EX(prev_execute_data); + + /* Free extra args before releasing the closure, + * as that may free the op_array. */ + zend_vm_stack_free_extra_args_ex(call_info, execute_data); + if (UNEXPECTED(call_info & ZEND_CALL_RELEASE_THIS)) { zend_object *object = Z_OBJ(execute_data->This); #if 0 @@ -55390,7 +55399,6 @@ zend_leave_helper_SPEC_LABEL: OBJ_RELEASE(ZEND_CLOSURE_OBJECT(EX(func))); } - zend_vm_stack_free_extra_args_ex(call_info, execute_data); old_execute_data = execute_data; execute_data = EX(prev_execute_data); zend_vm_stack_free_call_frame_ex(call_info, old_execute_data); |