com php-src: Properly cleanup on wrong ZEND_OVERLOADED_FUNC TION call: Zend/zend_vm_def.h Zend/zend_vm_ex ecute.h
| From: | Dmitry Stogov | Date: | Tue, 22 Sep 2015 20:51:30 +0000 |
| Subject: | com php-src: Properly cleanup on wrong ZEND_OVERLOADED_FUNC TION call: Zend/zend_vm_def.h Zend/zend_vm_ex ecute.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-89120@lists.php.net to get a copy of this message | ||
Commit: f9ec5be8885fe6dd04a2f7d3ae4c98bd1672f9ec
Author: Dmitry Stogov <dmitry@zend.com> Tue, 22 Sep 2015 23:51:30 +0300
Parents: e2e99f16e1cea47cc363483d26acfd41f5d2e814
Branches: PHP-7.0 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=f9ec5be8885fe6dd04a2f7d3ae4c98bd1672f9ec
Log:
Properly cleanup on wrong ZEND_OVERLOADED_FUNCTION call
Changed paths:
M Zend/zend_vm_def.h
M Zend/zend_vm_execute.h
Diff:
diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h
index 3d01572..62d9bbf 100644
--- a/Zend/zend_vm_def.h
+++ b/Zend/zend_vm_def.h
@@ -3806,33 +3806,29 @@ ZEND_VM_HANDLER(60, ZEND_DO_FCALL, ANY, ANY)
ZEND_VM_C_GOTO(fcall_end);
}
} else { /* ZEND_OVERLOADED_FUNCTION */
- EG(scope) = fbc->common.scope;
-
- ZVAL_NULL(EX_VAR(opline->result.var));
-
/* Not sure what should be done here if it's a static method */
object = Z_OBJ(call->This);
- if (EXPECTED(object != NULL)) {
- call->prev_execute_data = execute_data;
- EG(current_execute_data) = call;
- object->handlers->call_method(fbc->common.function_name, object, call,
EX_VAR(opline->result.var));
- EG(current_execute_data) = call->prev_execute_data;
- } else {
- zend_throw_error(NULL, "Cannot call overloaded function for non-object");
-#if 0
- //TODO: implement clean exit ???
+ if (UNEXPECTED(object == NULL)) {
zend_vm_stack_free_args(call);
-
- zend_vm_stack_free_call_frame(call);
-
if (fbc->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY) {
zend_string_release(fbc->common.function_name);
}
efree(fbc);
-#endif
+ zend_vm_stack_free_call_frame(call);
+
+ zend_throw_error(NULL, "Cannot call overloaded function for non-object");
HANDLE_EXCEPTION();
}
+ EG(scope) = fbc->common.scope;
+
+ ZVAL_NULL(EX_VAR(opline->result.var));
+
+ call->prev_execute_data = execute_data;
+ EG(current_execute_data) = call;
+ object->handlers->call_method(fbc->common.function_name, object, call,
EX_VAR(opline->result.var));
+ EG(current_execute_data) = call->prev_execute_data;
+
zend_vm_stack_free_args(call);
if (fbc->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY) {
diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h
index 7d1d726..b9fa6f5 100644
--- a/Zend/zend_vm_execute.h
+++ b/Zend/zend_vm_execute.h
@@ -860,33 +860,29 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL
ZEND_DO_FCALL_SPEC_HANDLER(ZEND_OPC
goto fcall_end;
}
} else { /* ZEND_OVERLOADED_FUNCTION */
- EG(scope) = fbc->common.scope;
-
- ZVAL_NULL(EX_VAR(opline->result.var));
-
/* Not sure what should be done here if it's a static method */
object = Z_OBJ(call->This);
- if (EXPECTED(object != NULL)) {
- call->prev_execute_data = execute_data;
- EG(current_execute_data) = call;
- object->handlers->call_method(fbc->common.function_name, object, call,
EX_VAR(opline->result.var));
- EG(current_execute_data) = call->prev_execute_data;
- } else {
- zend_throw_error(NULL, "Cannot call overloaded function for non-object");
-#if 0
- //TODO: implement clean exit ???
+ if (UNEXPECTED(object == NULL)) {
zend_vm_stack_free_args(call);
-
- zend_vm_stack_free_call_frame(call);
-
if (fbc->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY) {
zend_string_release(fbc->common.function_name);
}
efree(fbc);
-#endif
+ zend_vm_stack_free_call_frame(call);
+
+ zend_throw_error(NULL, "Cannot call overloaded function for non-object");
HANDLE_EXCEPTION();
}
+ EG(scope) = fbc->common.scope;
+
+ ZVAL_NULL(EX_VAR(opline->result.var));
+
+ call->prev_execute_data = execute_data;
+ EG(current_execute_data) = call;
+ object->handlers->call_method(fbc->common.function_name, object, call,
EX_VAR(opline->result.var));
+ EG(current_execute_data) = call->prev_execute_data;
+
zend_vm_stack_free_args(call);
if (fbc->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY) {