]> granicus.if.org Git - php/commitdiff
Safe destruction (variables and arguments may need to be cuptured by exception)
authorDmitry Stogov <dmitry@zend.com>
Thu, 16 Apr 2015 18:45:40 +0000 (21:45 +0300)
committerDmitry Stogov <dmitry@zend.com>
Thu, 16 Apr 2015 18:45:40 +0000 (21:45 +0300)
Zend/zend_execute.c
Zend/zend_execute.h

index 04c33f841508296d179ce9369b8db78945f075fa..a0bd3bd8975c5a8d3ae679be646b0cc11378bf6b 100644 (file)
@@ -1806,7 +1806,15 @@ static zend_always_inline void i_free_compiled_variables(zend_execute_data *exec
        zval *cv = EX_VAR_NUM(0);
        zval *end = cv + EX(func)->op_array.last_var;
        while (EXPECTED(cv != end)) {
-               zval_ptr_dtor(cv);
+               if (Z_REFCOUNTED_P(cv)) {
+                       if (!Z_DELREF_P(cv)) {
+                               zend_refcounted *r = Z_COUNTED_P(cv);
+                               ZVAL_NULL(cv);
+                               zval_dtor_func_for_ptr(r);
+                       } else {
+                               GC_ZVAL_CHECK_POSSIBLE_ROOT(cv);
+                       }
+               }
                cv++;
        }
 }
index 4dfed1830d1d1ea14a61c78e0c89feaba11c4168..67958cf32c97dfadea2a0a9f826fb8d1acc35d0a 100644 (file)
@@ -199,7 +199,15 @@ static zend_always_inline void zend_vm_stack_free_extra_args_ex(uint32_t call_in
                zval *p = end + (ZEND_CALL_NUM_ARGS(call) - call->func->op_array.num_args);
                do {
                        p--;
-                       i_zval_ptr_dtor(p ZEND_FILE_LINE_CC);
+                       if (Z_REFCOUNTED_P(p)) {
+                               if (!Z_DELREF_P(p)) {
+                                       zend_refcounted *r = Z_COUNTED_P(p);
+                                       ZVAL_NULL(p);
+                                       zval_dtor_func_for_ptr(r);
+                               } else {
+                                       GC_ZVAL_CHECK_POSSIBLE_ROOT(p);
+                               }
+                       }
                } while (p != end);
        }
 }
@@ -219,7 +227,13 @@ static zend_always_inline void zend_vm_stack_free_args(zend_execute_data *call)
 
                do {
                        p--;
-                       zval_ptr_dtor_nogc(p);
+                       if (Z_REFCOUNTED_P(p)) {
+                               if (!Z_DELREF_P(p)) {
+                                       zend_refcounted *r = Z_COUNTED_P(p);
+                                       ZVAL_NULL(p);
+                                       zval_dtor_func_for_ptr(r);
+                               }
+                       }
                } while (p != end);
        }
 }