]> granicus.if.org Git - php/commitdiff
Don't initialize return value before calling user functions
authorDmitry Stogov <dmitry@zend.com>
Wed, 17 Apr 2019 23:31:12 +0000 (02:31 +0300)
committerDmitry Stogov <dmitry@zend.com>
Wed, 17 Apr 2019 23:31:12 +0000 (02:31 +0300)
Zend/zend_vm_def.h
Zend/zend_vm_execute.h

index a853b866538677757675aed96e81a090d028b6d0..9f2fba4fbf6cc2b3314caf267aaee1bb83ffeaee 100644 (file)
@@ -3878,7 +3878,6 @@ ZEND_VM_HOT_HANDLER(130, ZEND_DO_UCALL, ANY, ANY, SPEC(RETVAL))
        ret = NULL;
        if (RETURN_VALUE_USED(opline)) {
                ret = EX_VAR(opline->result.var);
-               ZVAL_NULL(ret);
        }
 
        call->prev_execute_data = execute_data;
@@ -3903,7 +3902,6 @@ ZEND_VM_HOT_HANDLER(131, ZEND_DO_FCALL_BY_NAME, ANY, ANY, SPEC(RETVAL))
                ret = NULL;
                if (RETURN_VALUE_USED(opline)) {
                        ret = EX_VAR(opline->result.var);
-                       ZVAL_NULL(ret);
                }
 
                call->prev_execute_data = execute_data;
@@ -3991,7 +3989,6 @@ ZEND_VM_HOT_HANDLER(60, ZEND_DO_FCALL, ANY, ANY, SPEC(RETVAL))
                ret = NULL;
                if (RETURN_VALUE_USED(opline)) {
                        ret = EX_VAR(opline->result.var);
-                       ZVAL_NULL(ret);
                }
 
                call->prev_execute_data = execute_data;
@@ -5701,7 +5698,6 @@ ZEND_VM_HANDLER(73, ZEND_INCLUDE_OR_EVAL, CONST|TMPVAR|CV, ANY, EVAL)
 
                if (RETURN_VALUE_USED(opline)) {
                        return_value = EX_VAR(opline->result.var);
-                       ZVAL_NULL(return_value);
                }
 
                new_op_array->scope = EX(func)->op_array.scope;
@@ -7196,6 +7192,10 @@ ZEND_VM_HELPER(zend_dispatch_try_catch_finally_helper, ANY, ANY, uint32_t try_ca
                zend_generator_close(generator, 1);
                ZEND_VM_RETURN();
        } else {
+               /* We didn't execute RETURN, and have to initialize return_value */
+               if (EX(return_value)) {
+                       ZVAL_UNDEF(EX(return_value));
+               }
                ZEND_VM_DISPATCH_TO_HELPER(zend_leave_helper);
        }
 }
index d14af785b9381aa98d558378273b31c64b8ac19d..d4aac71756e0e559cd6d25dd8795bdaf88513132 100644 (file)
@@ -995,7 +995,6 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_DO_UCALL_SPEC_RETV
        ret = NULL;
        if (0) {
                ret = EX_VAR(opline->result.var);
-               ZVAL_NULL(ret);
        }
 
        call->prev_execute_data = execute_data;
@@ -1019,7 +1018,6 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_DO_UCALL_SPEC_RETV
        ret = NULL;
        if (1) {
                ret = EX_VAR(opline->result.var);
-               ZVAL_NULL(ret);
        }
 
        call->prev_execute_data = execute_data;
@@ -1044,7 +1042,6 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_DO_FCALL_BY_NAME_S
                ret = NULL;
                if (0) {
                        ret = EX_VAR(opline->result.var);
-                       ZVAL_NULL(ret);
                }
 
                call->prev_execute_data = execute_data;
@@ -1121,7 +1118,6 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_DO_FCALL_BY_NAME_S
                ret = NULL;
                if (1) {
                        ret = EX_VAR(opline->result.var);
-                       ZVAL_NULL(ret);
                }
 
                call->prev_execute_data = execute_data;
@@ -1209,7 +1205,6 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_DO_FCALL_SPEC_RETV
                ret = NULL;
                if (0) {
                        ret = EX_VAR(opline->result.var);
-                       ZVAL_NULL(ret);
                }
 
                call->prev_execute_data = execute_data;
@@ -1320,7 +1315,6 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_DO_FCALL_SPEC_RETV
                ret = NULL;
                if (1) {
                        ret = EX_VAR(opline->result.var);
-                       ZVAL_NULL(ret);
                }
 
                call->prev_execute_data = execute_data;
@@ -1964,6 +1958,10 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_dispatch_try_catch_finally_hel
                zend_generator_close(generator, 1);
                ZEND_VM_RETURN();
        } else {
+               /* We didn't execute RETURN, and have to initialize return_value */
+               if (EX(return_value)) {
+                       ZVAL_UNDEF(EX(return_value));
+               }
                ZEND_VM_TAIL_CALL(zend_leave_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU));
        }
 }
@@ -3454,7 +3452,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_CONST_HAN
 
                if (RETURN_VALUE_USED(opline)) {
                        return_value = EX_VAR(opline->result.var);
-                       ZVAL_NULL(return_value);
                }
 
                new_op_array->scope = EX(func)->op_array.scope;
@@ -12925,7 +12922,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_TMPVAR_HA
 
                if (RETURN_VALUE_USED(opline)) {
                        return_value = EX_VAR(opline->result.var);
-                       ZVAL_NULL(return_value);
                }
 
                new_op_array->scope = EX(func)->op_array.scope;
@@ -39960,7 +39956,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INCLUDE_OR_EVAL_SPEC_CV_HANDLE
 
                if (RETURN_VALUE_USED(opline)) {
                        return_value = EX_VAR(opline->result.var);
-                       ZVAL_NULL(return_value);
                }
 
                new_op_array->scope = EX(func)->op_array.scope;