diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 8415f9b87d9..c332201a8fe 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -3839,7 +3839,9 @@ static zend_always_inline void i_init_code_execute_data(zend_execute_data *execu EX(call) = NULL; EX(return_value) = return_value; - zend_attach_symbol_table(execute_data); + if (op_array->last_var) { + zend_attach_symbol_table(execute_data); + } if (!ZEND_MAP_PTR(op_array->run_time_cache)) { void *ptr; diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 9408b66408c..7105ca320bc 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -2863,7 +2863,9 @@ ZEND_VM_HOT_HELPER(zend_leave_helper, ANY, ANY) LOAD_NEXT_OPLINE(); ZEND_VM_LEAVE(); } else if (EXPECTED((call_info & ZEND_CALL_TOP) == 0)) { - zend_detach_symbol_table(execute_data); + if (EX(func)->op_array.last_var > 0) { + zend_detach_symbol_table(execute_data); + } zend_destroy_static_vars(&EX(func)->op_array); destroy_op_array(&EX(func)->op_array); efree_size(EX(func), sizeof(zend_op_array)); @@ -2874,7 +2876,9 @@ ZEND_VM_HOT_HELPER(zend_leave_helper, ANY, ANY) execute_data = EG(current_execute_data) = EX(prev_execute_data); zend_vm_stack_free_call_frame_ex(call_info, old_execute_data); - zend_attach_symbol_table(execute_data); + if (EX(func)->op_array.last_var > 0) { + zend_attach_symbol_table(execute_data); + } if (UNEXPECTED(EG(exception) != NULL)) { zend_rethrow_exception(execute_data); HANDLE_EXCEPTION_LEAVE(); @@ -2905,11 +2909,14 @@ ZEND_VM_HOT_HELPER(zend_leave_helper, ANY, ANY) } else /* if (call_kind == ZEND_CALL_TOP_CODE) */ { zend_array *symbol_table = EX(symbol_table); - zend_detach_symbol_table(execute_data); + if (EX(func)->op_array.last_var > 0) { + zend_detach_symbol_table(execute_data); + } old_execute_data = EX(prev_execute_data); while (old_execute_data) { if (old_execute_data->func && (ZEND_CALL_INFO(old_execute_data) & ZEND_CALL_HAS_SYMBOL_TABLE)) { - if (old_execute_data->symbol_table == symbol_table) { + if (old_execute_data->symbol_table == symbol_table + && old_execute_data->func->op_array.last_var > 0) { zend_attach_symbol_table(old_execute_data); } break; diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 6a6476b2ce5..d6e67c16dbd 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -1145,7 +1145,9 @@ static zend_never_inline ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_leave_helper LOAD_NEXT_OPLINE(); ZEND_VM_LEAVE(); } else if (EXPECTED((call_info & ZEND_CALL_TOP) == 0)) { - zend_detach_symbol_table(execute_data); + if (EX(func)->op_array.last_var > 0) { + zend_detach_symbol_table(execute_data); + } zend_destroy_static_vars(&EX(func)->op_array); destroy_op_array(&EX(func)->op_array); efree_size(EX(func), sizeof(zend_op_array)); @@ -1156,7 +1158,9 @@ static zend_never_inline ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_leave_helper execute_data = EG(current_execute_data) = EX(prev_execute_data); zend_vm_stack_free_call_frame_ex(call_info, old_execute_data); - zend_attach_symbol_table(execute_data); + if (EX(func)->op_array.last_var > 0) { + zend_attach_symbol_table(execute_data); + } if (UNEXPECTED(EG(exception) != NULL)) { zend_rethrow_exception(execute_data); HANDLE_EXCEPTION_LEAVE(); @@ -1187,11 +1191,14 @@ static zend_never_inline ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_leave_helper } else /* if (call_kind == ZEND_CALL_TOP_CODE) */ { zend_array *symbol_table = EX(symbol_table); - zend_detach_symbol_table(execute_data); + if (EX(func)->op_array.last_var > 0) { + zend_detach_symbol_table(execute_data); + } old_execute_data = EX(prev_execute_data); while (old_execute_data) { if (old_execute_data->func && (ZEND_CALL_INFO(old_execute_data) & ZEND_CALL_HAS_SYMBOL_TABLE)) { - if (old_execute_data->symbol_table == symbol_table) { + if (old_execute_data->symbol_table == symbol_table + && old_execute_data->func->op_array.last_var > 0) { zend_attach_symbol_table(old_execute_data); } break; @@ -55398,7 +55405,9 @@ zend_leave_helper_SPEC_LABEL: LOAD_NEXT_OPLINE(); ZEND_VM_LEAVE(); } else if (EXPECTED((call_info & ZEND_CALL_TOP) == 0)) { - zend_detach_symbol_table(execute_data); + if (EX(func)->op_array.last_var > 0) { + zend_detach_symbol_table(execute_data); + } zend_destroy_static_vars(&EX(func)->op_array); destroy_op_array(&EX(func)->op_array); efree_size(EX(func), sizeof(zend_op_array)); @@ -55409,7 +55418,9 @@ zend_leave_helper_SPEC_LABEL: execute_data = EG(current_execute_data) = EX(prev_execute_data); zend_vm_stack_free_call_frame_ex(call_info, old_execute_data); - zend_attach_symbol_table(execute_data); + if (EX(func)->op_array.last_var > 0) { + zend_attach_symbol_table(execute_data); + } if (UNEXPECTED(EG(exception) != NULL)) { zend_rethrow_exception(execute_data); HANDLE_EXCEPTION_LEAVE(); @@ -55440,11 +55451,14 @@ zend_leave_helper_SPEC_LABEL: } else /* if (call_kind == ZEND_CALL_TOP_CODE) */ { zend_array *symbol_table = EX(symbol_table); - zend_detach_symbol_table(execute_data); + if (EX(func)->op_array.last_var > 0) { + zend_detach_symbol_table(execute_data); + } old_execute_data = EX(prev_execute_data); while (old_execute_data) { if (old_execute_data->func && (ZEND_CALL_INFO(old_execute_data) & ZEND_CALL_HAS_SYMBOL_TABLE)) { - if (old_execute_data->symbol_table == symbol_table) { + if (old_execute_data->symbol_table == symbol_table + && old_execute_data->func->op_array.last_var > 0) { zend_attach_symbol_table(old_execute_data); } break;