summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntony Dovgal <tony2001@php.net>2008-08-10 21:23:21 +0000
committerAntony Dovgal <tony2001@php.net>2008-08-10 21:23:21 +0000
commita270199067a5dbba1a98248cb0e56bdd5428d967 (patch)
treed0eb5e55730e10581699f7828f4332a04484d67a
parent07d8c7dfa0a2a9a252af396ce6bad08c96245665 (diff)
downloadphp-git-a270199067a5dbba1a98248cb0e56bdd5428d967.tar.gz
fix bug reported by Henrique
add test
-rw-r--r--Zend/tests/foreach_unset_globals.phpt21
-rw-r--r--Zend/zend_vm_def.h4
-rw-r--r--Zend/zend_vm_execute.h48
3 files changed, 60 insertions, 13 deletions
diff --git a/Zend/tests/foreach_unset_globals.phpt b/Zend/tests/foreach_unset_globals.phpt
new file mode 100644
index 0000000000..1cc03f2a40
--- /dev/null
+++ b/Zend/tests/foreach_unset_globals.phpt
@@ -0,0 +1,21 @@
+--TEST--
+traverse an array and use its keys to unset GLOBALS
+--FILE--
+<?php
+
+$arr = array("a" => 1, "b" => 2);
+foreach ($arr as $key => $val) {
+ unset($GLOBALS[$key]);
+}
+
+var_dump($arr);
+echo "Done\n";
+?>
+--EXPECTF--
+array(2) {
+ [u"a"]=>
+ int(1)
+ [u"b"]=>
+ int(2)
+}
+Done
diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h
index efea17dd9f..a94c913541 100644
--- a/Zend/zend_vm_def.h
+++ b/Zend/zend_vm_def.h
@@ -3554,7 +3554,9 @@ ZEND_VM_HANDLER(75, ZEND_UNSET_DIM, VAR|UNUSED|CV, CONST|TMP|VAR|CV)
offset_len = norm_len;
free_offset = 1;
}
- } else if (OP2_TYPE == IS_CV || OP2_TYPE == IS_VAR) {
+ }
+
+ if (OP2_TYPE == IS_CV || OP2_TYPE == IS_VAR) {
Z_ADDREF_P(offset);
}
diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h
index 1420a54bc5..0d49701a36 100644
--- a/Zend/zend_vm_execute.h
+++ b/Zend/zend_vm_execute.h
@@ -11078,7 +11078,9 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HAND
offset_len = norm_len;
free_offset = 1;
}
- } else if (IS_CONST == IS_CV || IS_CONST == IS_VAR) {
+ }
+
+ if (IS_CONST == IS_CV || IS_CONST == IS_VAR) {
Z_ADDREF_P(offset);
}
@@ -12920,7 +12922,9 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLE
offset_len = norm_len;
free_offset = 1;
}
- } else if (IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) {
+ }
+
+ if (IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) {
Z_ADDREF_P(offset);
}
@@ -14809,7 +14813,9 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLE
offset_len = norm_len;
free_offset = 1;
}
- } else if (IS_VAR == IS_CV || IS_VAR == IS_VAR) {
+ }
+
+ if (IS_VAR == IS_CV || IS_VAR == IS_VAR) {
Z_ADDREF_P(offset);
}
@@ -17314,7 +17320,9 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER
offset_len = norm_len;
free_offset = 1;
}
- } else if (IS_CV == IS_CV || IS_CV == IS_VAR) {
+ }
+
+ if (IS_CV == IS_CV || IS_CV == IS_VAR) {
Z_ADDREF_P(offset);
}
@@ -18594,7 +18602,9 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_UNUSED_CONST_HANDLER(ZEND_OPCODE_H
offset_len = norm_len;
free_offset = 1;
}
- } else if (IS_CONST == IS_CV || IS_CONST == IS_VAR) {
+ }
+
+ if (IS_CONST == IS_CV || IS_CONST == IS_VAR) {
Z_ADDREF_P(offset);
}
@@ -19724,7 +19734,9 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_HAN
offset_len = norm_len;
free_offset = 1;
}
- } else if (IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) {
+ }
+
+ if (IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) {
Z_ADDREF_P(offset);
}
@@ -20854,7 +20866,9 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_HAN
offset_len = norm_len;
free_offset = 1;
}
- } else if (IS_VAR == IS_CV || IS_VAR == IS_VAR) {
+ }
+
+ if (IS_VAR == IS_CV || IS_VAR == IS_VAR) {
Z_ADDREF_P(offset);
}
@@ -22252,7 +22266,9 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_UNUSED_CV_HANDLER(ZEND_OPCODE_HAND
offset_len = norm_len;
free_offset = 1;
}
- } else if (IS_CV == IS_CV || IS_CV == IS_VAR) {
+ }
+
+ if (IS_CV == IS_CV || IS_CV == IS_VAR) {
Z_ADDREF_P(offset);
}
@@ -25394,7 +25410,9 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HANDL
offset_len = norm_len;
free_offset = 1;
}
- } else if (IS_CONST == IS_CV || IS_CONST == IS_VAR) {
+ }
+
+ if (IS_CONST == IS_CV || IS_CONST == IS_VAR) {
Z_ADDREF_P(offset);
}
@@ -27114,7 +27132,9 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER
offset_len = norm_len;
free_offset = 1;
}
- } else if (IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) {
+ }
+
+ if (IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) {
Z_ADDREF_P(offset);
}
@@ -28880,7 +28900,9 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER
offset_len = norm_len;
free_offset = 1;
}
- } else if (IS_VAR == IS_CV || IS_VAR == IS_VAR) {
+ }
+
+ if (IS_VAR == IS_CV || IS_VAR == IS_VAR) {
Z_ADDREF_P(offset);
}
@@ -31150,7 +31172,9 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER_
offset_len = norm_len;
free_offset = 1;
}
- } else if (IS_CV == IS_CV || IS_CV == IS_VAR) {
+ }
+
+ if (IS_CV == IS_CV || IS_CV == IS_VAR) {
Z_ADDREF_P(offset);
}