summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2004-10-05 09:09:18 +0000
committerDmitry Stogov <dmitry@php.net>2004-10-05 09:09:18 +0000
commit3d383e45dc1b026074a9bf75c830b96242e33a44 (patch)
tree769b344fc69d338d6c55891de00c33ab234052ef
parent3f35c6a6cc69bc3054fad4a7031ea780baed8945 (diff)
downloadphp-git-3d383e45dc1b026074a9bf75c830b96242e33a44.tar.gz
Fixed unset() bug that was introduced with CV optimization patch
-rw-r--r--Zend/tests/unset_cv11.phpt21
-rw-r--r--Zend/zend_execute.c4
-rw-r--r--Zend/zend_vm_handlers.h5
3 files changed, 29 insertions, 1 deletions
diff --git a/Zend/tests/unset_cv11.phpt b/Zend/tests/unset_cv11.phpt
new file mode 100644
index 0000000000..152ea0229b
--- /dev/null
+++ b/Zend/tests/unset_cv11.phpt
@@ -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
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
index 9e7c0d2b57..52a437bfd0 100644
--- a/Zend/zend_execute.c
+++ b/Zend/zend_execute.c
@@ -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:
diff --git a/Zend/zend_vm_handlers.h b/Zend/zend_vm_handlers.h
index dc8a1f1899..0f2c312f12 100644
--- a/Zend/zend_vm_handlers.h
+++ b/Zend/zend_vm_handlers.h
@@ -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: