]> granicus.if.org Git - php/commitdiff
Fixed unset() bug that was introduced with CV optimization patch
authorDmitry Stogov <dmitry@php.net>
Tue, 5 Oct 2004 09:09:18 +0000 (09:09 +0000)
committerDmitry Stogov <dmitry@php.net>
Tue, 5 Oct 2004 09:09:18 +0000 (09:09 +0000)
Zend/tests/unset_cv11.phpt [new file with mode: 0644]
Zend/zend_execute.c
Zend/zend_vm_handlers.h

diff --git a/Zend/tests/unset_cv11.phpt b/Zend/tests/unset_cv11.phpt
new file mode 100644 (file)
index 0000000..152ea02
--- /dev/null
@@ -0,0 +1,21 @@
+--TEST--
+unset() CV 11 (unset() of copy destoies original value)
+--FILE--
+<?php
+$x = array("default"=>"ok");
+var_dump($x);
+$cf = $x;
+unset($cf['default']);
+var_dump($x);
+echo "ok\n";
+?>
+--EXPECT--
+array(1) {
+  ["default"]=>
+  string(2) "ok"
+}
+array(1) {
+  ["default"]=>
+  string(2) "ok"
+}
+ok
index 9e7c0d2b5781bdd278c9cce767ccb641a16b18cc..52a437bfd096dd045fbb33896c71b00471c8e5a7 100644 (file)
@@ -195,6 +195,7 @@ static inline zval *_get_zval_ptr(znode *node, temp_variable *Ts, zend_free_op *
                                if (zend_hash_quick_find(EG(active_symbol_table), cv->name, cv->name_len+1, cv->hash_value, (void **)ptr)==FAILURE) {
                                        switch (type) {
                                                case BP_VAR_R:
+                                               case BP_VAR_UNSET:
                                                        zend_error(E_NOTICE, "Undefined variable: %s", cv->name);
                                                        /* break missing intentionally */
                                                case BP_VAR_IS:
@@ -228,6 +229,7 @@ static inline zval **_get_zval_ptr_ptr(znode *node, temp_variable *Ts, zend_free
                        if (zend_hash_quick_find(EG(active_symbol_table), cv->name, cv->name_len+1, cv->hash_value, (void **)ptr)==FAILURE) {
                                switch (type) {
                                        case BP_VAR_R:
+                                       case BP_VAR_UNSET:
                                                zend_error(E_NOTICE, "Undefined variable:  %s", cv->name);
                                                /* break missing intentionally */
                                        case BP_VAR_IS:
@@ -315,6 +317,7 @@ static inline zval *_get_zval_ptr_cv(znode *node, temp_variable *Ts, zend_free_o
                if (zend_hash_quick_find(EG(active_symbol_table), cv->name, cv->name_len+1, cv->hash_value, (void **)ptr)==FAILURE) {
                        switch (type) {
                                case BP_VAR_R:
+                               case BP_VAR_UNSET:
                                        zend_error(E_NOTICE, "Undefined variable: %s", cv->name);
                                        /* break missing intentionally */
                                case BP_VAR_IS:
@@ -373,6 +376,7 @@ static inline zval **_get_zval_ptr_ptr_cv(znode *node, temp_variable *Ts, zend_f
                if (zend_hash_quick_find(EG(active_symbol_table), cv->name, cv->name_len+1, cv->hash_value, (void **)ptr)==FAILURE) {
                        switch (type) {
                                case BP_VAR_R:
+                               case BP_VAR_UNSET:
                                        zend_error(E_NOTICE, "Undefined variable:  %s", cv->name);
                                        /* break missing intentionally */
                                case BP_VAR_IS:
index dc8a1f1899e321f36c9248d41406fcf077a5d32b..0f2c312f124b3c7788c8b9ebaa81940b6f116db0 100644 (file)
@@ -3238,13 +3238,16 @@ ZEND_VM_HANDLER(ZEND_UNSET_DIM_OBJ)
 {
        zend_op *opline = EX(opline);
        zend_free_op free_op1, free_op2;
-       zval **container = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_R);
+       zval **container = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_UNSET);
        zval *offset = GET_OP2_ZVAL_PTR(BP_VAR_R);
        long index;
 
        if (container) {
                HashTable *ht;
 
+               if (OP1_TYPE == IS_CV && container != &EG(uninitialized_zval_ptr)) {
+                       SEPARATE_ZVAL_IF_NOT_REF(container);
+               }
                if (opline->extended_value == ZEND_UNSET_DIM) {
                        switch (Z_TYPE_PP(container)) {
                                case IS_ARRAY: