summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2011-07-06 12:04:02 +0000
committerDmitry Stogov <dmitry@php.net>2011-07-06 12:04:02 +0000
commitb7e124004f24896248827eb969909f1e92eafc39 (patch)
tree4a3a5afdcb21e4c752407cdc77c40efdfd16f4ed
parentfdd4aa70730b999ccb7f481bce9df3a1c3666839 (diff)
downloadphp-git-b7e124004f24896248827eb969909f1e92eafc39.tar.gz
Fixed bug #55135 (Array keys are no longer type casted in unset())
-rw-r--r--Zend/tests/bug55135.phpt38
-rw-r--r--Zend/zend_vm_def.h7
-rw-r--r--Zend/zend_vm_execute.h84
3 files changed, 116 insertions, 13 deletions
diff --git a/Zend/tests/bug55135.phpt b/Zend/tests/bug55135.phpt
new file mode 100644
index 0000000000..f6d0aafaca
--- /dev/null
+++ b/Zend/tests/bug55135.phpt
@@ -0,0 +1,38 @@
+--TEST--
+Bug #55135 (Array keys are no longer type casted in unset())
+--FILE--
+<?php
+// This fails.
+$array = array(1 => 2);
+$a = "1";
+unset($array[$a]);
+print_r($array);
+
+// Those works.
+$array = array(1 => 2);
+$a = 1;
+unset($array[$a]);
+print_r($array);
+
+$array = array(1 => 2);
+unset($array[1]);
+print_r($array);
+
+$array = array(1 => 2);
+$a = 1;
+unset($array["1"]);
+print_r($array);
+?>
+--EXPECT--
+Array
+(
+)
+Array
+(
+)
+Array
+(
+)
+Array
+(
+)
diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h
index 77d208ce53..aad9585a8f 100644
--- a/Zend/zend_vm_def.h
+++ b/Zend/zend_vm_def.h
@@ -3917,7 +3917,6 @@ ZEND_VM_HANDLER(75, ZEND_UNSET_DIM, VAR|UNUSED|CV, CONST|TMP|VAR|CV)
case IS_RESOURCE:
case IS_BOOL:
case IS_LONG:
-ZEND_VM_C_LABEL(num_index_dim):
hval = Z_LVAL_P(offset);
zend_hash_index_del(ht, hval);
break;
@@ -3944,6 +3943,12 @@ ZEND_VM_C_LABEL(num_index_dim):
zval_ptr_dtor(&offset);
}
break;
+ZEND_VM_C_LABEL(num_index_dim):
+ zend_hash_index_del(ht, hval);
+ if (OP2_TYPE == IS_CV || OP2_TYPE == IS_VAR) {
+ zval_ptr_dtor(&offset);
+ }
+ break;
case IS_NULL:
zend_hash_del(ht, "", sizeof(""));
break;
diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h
index fd726eb880..569254dcf1 100644
--- a/Zend/zend_vm_execute.h
+++ b/Zend/zend_vm_execute.h
@@ -13526,7 +13526,6 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HAND
case IS_RESOURCE:
case IS_BOOL:
case IS_LONG:
-num_index_dim:
hval = Z_LVAL_P(offset);
zend_hash_index_del(ht, hval);
break;
@@ -13553,6 +13552,12 @@ num_index_dim:
zval_ptr_dtor(&offset);
}
break;
+num_index_dim:
+ zend_hash_index_del(ht, hval);
+ if (IS_CONST == IS_CV || IS_CONST == IS_VAR) {
+ zval_ptr_dtor(&offset);
+ }
+ break;
case IS_NULL:
zend_hash_del(ht, "", sizeof(""));
break;
@@ -15506,7 +15511,6 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLE
case IS_RESOURCE:
case IS_BOOL:
case IS_LONG:
-num_index_dim:
hval = Z_LVAL_P(offset);
zend_hash_index_del(ht, hval);
break;
@@ -15533,6 +15537,12 @@ num_index_dim:
zval_ptr_dtor(&offset);
}
break;
+num_index_dim:
+ zend_hash_index_del(ht, hval);
+ if (IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) {
+ zval_ptr_dtor(&offset);
+ }
+ break;
case IS_NULL:
zend_hash_del(ht, "", sizeof(""));
break;
@@ -17682,7 +17692,6 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLE
case IS_RESOURCE:
case IS_BOOL:
case IS_LONG:
-num_index_dim:
hval = Z_LVAL_P(offset);
zend_hash_index_del(ht, hval);
break;
@@ -17709,6 +17718,12 @@ num_index_dim:
zval_ptr_dtor(&offset);
}
break;
+num_index_dim:
+ zend_hash_index_del(ht, hval);
+ if (IS_VAR == IS_CV || IS_VAR == IS_VAR) {
+ zval_ptr_dtor(&offset);
+ }
+ break;
case IS_NULL:
zend_hash_del(ht, "", sizeof(""));
break;
@@ -20670,7 +20685,6 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER
case IS_RESOURCE:
case IS_BOOL:
case IS_LONG:
-num_index_dim:
hval = Z_LVAL_P(offset);
zend_hash_index_del(ht, hval);
break;
@@ -20697,6 +20711,12 @@ num_index_dim:
zval_ptr_dtor(&offset);
}
break;
+num_index_dim:
+ zend_hash_index_del(ht, hval);
+ if (IS_CV == IS_CV || IS_CV == IS_VAR) {
+ zval_ptr_dtor(&offset);
+ }
+ break;
case IS_NULL:
zend_hash_del(ht, "", sizeof(""));
break;
@@ -21992,7 +22012,6 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_UNUSED_CONST_HANDLER(ZEND_OPCODE_H
case IS_RESOURCE:
case IS_BOOL:
case IS_LONG:
-num_index_dim:
hval = Z_LVAL_P(offset);
zend_hash_index_del(ht, hval);
break;
@@ -22019,6 +22038,12 @@ num_index_dim:
zval_ptr_dtor(&offset);
}
break;
+num_index_dim:
+ zend_hash_index_del(ht, hval);
+ if (IS_CONST == IS_CV || IS_CONST == IS_VAR) {
+ zval_ptr_dtor(&offset);
+ }
+ break;
case IS_NULL:
zend_hash_del(ht, "", sizeof(""));
break;
@@ -23135,7 +23160,6 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_HAN
case IS_RESOURCE:
case IS_BOOL:
case IS_LONG:
-num_index_dim:
hval = Z_LVAL_P(offset);
zend_hash_index_del(ht, hval);
break;
@@ -23162,6 +23186,12 @@ num_index_dim:
zval_ptr_dtor(&offset);
}
break;
+num_index_dim:
+ zend_hash_index_del(ht, hval);
+ if (IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) {
+ zval_ptr_dtor(&offset);
+ }
+ break;
case IS_NULL:
zend_hash_del(ht, "", sizeof(""));
break;
@@ -24278,7 +24308,6 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_HAN
case IS_RESOURCE:
case IS_BOOL:
case IS_LONG:
-num_index_dim:
hval = Z_LVAL_P(offset);
zend_hash_index_del(ht, hval);
break;
@@ -24305,6 +24334,12 @@ num_index_dim:
zval_ptr_dtor(&offset);
}
break;
+num_index_dim:
+ zend_hash_index_del(ht, hval);
+ if (IS_VAR == IS_CV || IS_VAR == IS_VAR) {
+ zval_ptr_dtor(&offset);
+ }
+ break;
case IS_NULL:
zend_hash_del(ht, "", sizeof(""));
break;
@@ -25687,7 +25722,6 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_UNUSED_CV_HANDLER(ZEND_OPCODE_HAND
case IS_RESOURCE:
case IS_BOOL:
case IS_LONG:
-num_index_dim:
hval = Z_LVAL_P(offset);
zend_hash_index_del(ht, hval);
break;
@@ -25714,6 +25748,12 @@ num_index_dim:
zval_ptr_dtor(&offset);
}
break;
+num_index_dim:
+ zend_hash_index_del(ht, hval);
+ if (IS_CV == IS_CV || IS_CV == IS_VAR) {
+ zval_ptr_dtor(&offset);
+ }
+ break;
case IS_NULL:
zend_hash_del(ht, "", sizeof(""));
break;
@@ -28838,7 +28878,6 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HANDL
case IS_RESOURCE:
case IS_BOOL:
case IS_LONG:
-num_index_dim:
hval = Z_LVAL_P(offset);
zend_hash_index_del(ht, hval);
break;
@@ -28865,6 +28904,12 @@ num_index_dim:
zval_ptr_dtor(&offset);
}
break;
+num_index_dim:
+ zend_hash_index_del(ht, hval);
+ if (IS_CONST == IS_CV || IS_CONST == IS_VAR) {
+ zval_ptr_dtor(&offset);
+ }
+ break;
case IS_NULL:
zend_hash_del(ht, "", sizeof(""));
break;
@@ -30692,7 +30737,6 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER
case IS_RESOURCE:
case IS_BOOL:
case IS_LONG:
-num_index_dim:
hval = Z_LVAL_P(offset);
zend_hash_index_del(ht, hval);
break;
@@ -30719,6 +30763,12 @@ num_index_dim:
zval_ptr_dtor(&offset);
}
break;
+num_index_dim:
+ zend_hash_index_del(ht, hval);
+ if (IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) {
+ zval_ptr_dtor(&offset);
+ }
+ break;
case IS_NULL:
zend_hash_del(ht, "", sizeof(""));
break;
@@ -32741,7 +32791,6 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER
case IS_RESOURCE:
case IS_BOOL:
case IS_LONG:
-num_index_dim:
hval = Z_LVAL_P(offset);
zend_hash_index_del(ht, hval);
break;
@@ -32768,6 +32817,12 @@ num_index_dim:
zval_ptr_dtor(&offset);
}
break;
+num_index_dim:
+ zend_hash_index_del(ht, hval);
+ if (IS_VAR == IS_CV || IS_VAR == IS_VAR) {
+ zval_ptr_dtor(&offset);
+ }
+ break;
case IS_NULL:
zend_hash_del(ht, "", sizeof(""));
break;
@@ -35466,7 +35521,6 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER_
case IS_RESOURCE:
case IS_BOOL:
case IS_LONG:
-num_index_dim:
hval = Z_LVAL_P(offset);
zend_hash_index_del(ht, hval);
break;
@@ -35493,6 +35547,12 @@ num_index_dim:
zval_ptr_dtor(&offset);
}
break;
+num_index_dim:
+ zend_hash_index_del(ht, hval);
+ if (IS_CV == IS_CV || IS_CV == IS_VAR) {
+ zval_ptr_dtor(&offset);
+ }
+ break;
case IS_NULL:
zend_hash_del(ht, "", sizeof(""));
break;