summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2008-08-07 11:45:35 +0000
committerDmitry Stogov <dmitry@php.net>2008-08-07 11:45:35 +0000
commitc1e5b1345d87b093d415cbd83ac276b99af173f8 (patch)
treeabe07dd6405f06e0bf9f752c81f8bf3b1c96f1e1
parent333ae016f0730645ebbf0a2bea5020039f01bd52 (diff)
downloadphp-git-c1e5b1345d87b093d415cbd83ac276b99af173f8.tar.gz
Fixed bug #45742 (Wrong class array inpretetion using constant indexes)
-rw-r--r--Zend/tests/bug45742.phpt24
-rw-r--r--Zend/zend_hash.c24
2 files changed, 44 insertions, 4 deletions
diff --git a/Zend/tests/bug45742.phpt b/Zend/tests/bug45742.phpt
new file mode 100644
index 0000000000..b21e093049
--- /dev/null
+++ b/Zend/tests/bug45742.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Bug #45742 Wrong class array inpretetion using constant indexes
+--FILE--
+<?php
+class Constants {
+ // Needs to be equal
+ const A = 1;
+ const B = 1;
+}
+
+class ArrayProperty {
+ public static $array = array(
+ Constants::A => 23,
+ Constants::B => 42,
+ );
+}
+
+var_dump( ArrayProperty::$array );
+?>
+--EXPECT--
+array(1) {
+ [1]=>
+ int(23)
+}
diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c
index b4c8e7a794..5dc314e182 100644
--- a/Zend/zend_hash.c
+++ b/Zend/zend_hash.c
@@ -1197,14 +1197,22 @@ ZEND_API int zend_hash_update_current_key_ex(HashTable *ht, int key_type, const
if (mode & HASH_UPDATE_KEY_IF_BEFORE) {
break;
} else {
- zend_hash_index_del(ht, p->h);
+ if (p->nKeyLength) {
+ zend_hash_del(ht, p->arKey, p->nKeyLength);
+ } else {
+ zend_hash_index_del(ht, p->h);
+ }
return FAILURE;
}
} else {
if (mode & HASH_UPDATE_KEY_IF_AFTER) {
break;
} else {
- zend_hash_index_del(ht, p->h);
+ if (p->nKeyLength) {
+ zend_hash_del(ht, p->arKey, p->nKeyLength);
+ } else {
+ zend_hash_index_del(ht, p->h);
+ }
return FAILURE;
}
}
@@ -1234,14 +1242,22 @@ ZEND_API int zend_hash_update_current_key_ex(HashTable *ht, int key_type, const
if (mode & HASH_UPDATE_KEY_IF_BEFORE) {
break;
} else {
- zend_hash_del(ht, p->arKey, p->nKeyLength);
+ if (p->nKeyLength) {
+ zend_hash_del(ht, p->arKey, p->nKeyLength);
+ } else {
+ zend_hash_index_del(ht, p->h);
+ }
return FAILURE;
}
} else {
if (mode & HASH_UPDATE_KEY_IF_AFTER) {
break;
} else {
- zend_hash_del(ht, p->arKey, p->nKeyLength);
+ if (p->nKeyLength) {
+ zend_hash_del(ht, p->arKey, p->nKeyLength);
+ } else {
+ zend_hash_index_del(ht, p->h);
+ }
return FAILURE;
}
}