]> granicus.if.org Git - php/commitdiff
Destroy function arguments in direct order
authorDmitry Stogov <dmitry@zend.com>
Tue, 8 May 2018 12:28:57 +0000 (15:28 +0300)
committerDmitry Stogov <dmitry@zend.com>
Tue, 8 May 2018 12:28:57 +0000 (15:28 +0300)
Zend/zend_execute.h
ext/date/tests/bug53437.phpt

index 67bac91dd7ba0231eaf485ef512757f7fcbb2b43..42f289568c4357d1ed34c4011782edd768581195 100644 (file)
@@ -226,9 +226,8 @@ static zend_always_inline void zend_vm_stack_free_extra_args_ex(uint32_t call_in
 {
        if (UNEXPECTED(call_info & ZEND_CALL_FREE_EXTRA_ARGS)) {
                uint32_t count = ZEND_CALL_NUM_ARGS(call) - call->func->op_array.num_args;
-               zval *p = ZEND_CALL_VAR_NUM(call, call->func->op_array.last_var + call->func->op_array.T + count);
+               zval *p = ZEND_CALL_VAR_NUM(call, call->func->op_array.last_var + call->func->op_array.T);
                do {
-                       p--;
                        if (Z_REFCOUNTED_P(p)) {
                                zend_refcounted *r = Z_COUNTED_P(p);
                                if (!GC_DELREF(r)) {
@@ -238,6 +237,7 @@ static zend_always_inline void zend_vm_stack_free_extra_args_ex(uint32_t call_in
                                        gc_check_possible_root(r);
                                }
                        }
+                       p++;
                } while (--count);
        }
 }
@@ -252,11 +252,9 @@ static zend_always_inline void zend_vm_stack_free_args(zend_execute_data *call)
        uint32_t num_args = ZEND_CALL_NUM_ARGS(call);
 
        if (EXPECTED(num_args > 0)) {
-               zval *end = ZEND_CALL_ARG(call, 1);
-               zval *p = end + num_args;
+               zval *p = ZEND_CALL_ARG(call, 1);
 
                do {
-                       p--;
                        if (Z_REFCOUNTED_P(p)) {
                                zend_refcounted *r = Z_COUNTED_P(p);
                                if (!GC_DELREF(r)) {
@@ -264,7 +262,8 @@ static zend_always_inline void zend_vm_stack_free_args(zend_execute_data *call)
                                        zval_dtor_func(r);
                                }
                        }
-               } while (p != end);
+                       p++;
+               } while (--num_args);
        }
 }
 
index 0be9691a1401000aa2ab31daf5a072c5268aff60..3e5899057dea4bedd036b192f1612fcb1a05fe29 100644 (file)
@@ -23,15 +23,15 @@ foreach($dpu as $dt) {
 }
 ?>
 ==DONE==
---EXPECT--
+--EXPECTF--
 Original:
 2010-01-01 00:00:00
 2010-01-02 00:00:00
 2010-01-03 00:00:00
 
-object(DatePeriod)#1 (6) {
+object(DatePeriod)#%d (6) {
   ["start"]=>
-  object(DateTime)#2 (3) {
+  object(DateTime)#%d (3) {
     ["date"]=>
     string(26) "2010-01-01 00:00:00.000000"
     ["timezone_type"]=>
@@ -40,7 +40,7 @@ object(DatePeriod)#1 (6) {
     string(3) "UTC"
   }
   ["current"]=>
-  object(DateTime)#4 (3) {
+  object(DateTime)#%d (3) {
     ["date"]=>
     string(26) "2010-01-04 00:00:00.000000"
     ["timezone_type"]=>
@@ -51,7 +51,7 @@ object(DatePeriod)#1 (6) {
   ["end"]=>
   NULL
   ["interval"]=>
-  object(DateInterval)#5 (16) {
+  object(DateInterval)#%d (16) {
     ["y"]=>
     int(0)
     ["m"]=>
@@ -90,9 +90,9 @@ object(DatePeriod)#1 (6) {
   ["include_start_date"]=>
   bool(true)
 }
-object(DatePeriod)#5 (6) {
+object(DatePeriod)#%d (6) {
   ["start"]=>
-  object(DateTime)#10 (3) {
+  object(DateTime)#%d (3) {
     ["date"]=>
     string(26) "2010-01-01 00:00:00.000000"
     ["timezone_type"]=>
@@ -101,7 +101,7 @@ object(DatePeriod)#5 (6) {
     string(3) "UTC"
   }
   ["current"]=>
-  object(DateTime)#7 (3) {
+  object(DateTime)#%d (3) {
     ["date"]=>
     string(26) "2010-01-04 00:00:00.000000"
     ["timezone_type"]=>
@@ -112,7 +112,7 @@ object(DatePeriod)#5 (6) {
   ["end"]=>
   NULL
   ["interval"]=>
-  object(DateInterval)#8 (16) {
+  object(DateInterval)#%d (16) {
     ["y"]=>
     int(0)
     ["m"]=>