summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMoriyoshi Koizumi <moriyoshi@php.net>2003-10-03 22:41:43 +0000
committerMoriyoshi Koizumi <moriyoshi@php.net>2003-10-03 22:41:43 +0000
commit4859431fc11cd89ac09ab4e9e4e6be49a6d0a75e (patch)
tree4cab6fd5bb3314b40fdf68d3a34f9243ad90761d
parent149f786025c559bdcbebb069cab330aa162b3ac7 (diff)
downloadphp-git-4859431fc11cd89ac09ab4e9e4e6be49a6d0a75e.tar.gz
Fixed bug #24766 (strange result array from unpack())
-rw-r--r--Zend/zend_API.c20
-rw-r--r--ext/standard/tests/array/bug24766.phpt32
2 files changed, 33 insertions, 19 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index b616b2fca7..edba59c2eb 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -745,7 +745,7 @@ ZEND_API int add_assoc_long_ex(zval *arg, char *key, uint key_len, long n)
MAKE_STD_ZVAL(tmp);
ZVAL_LONG(tmp, n);
- return zend_hash_update(Z_ARRVAL_P(arg), key, key_len, (void *) &tmp, sizeof(zval *), NULL);
+ return zend_symtable_update(Z_ARRVAL_P(arg), key, key_len, (void *) &tmp, sizeof(zval *), NULL);
}
ZEND_API int add_assoc_null_ex(zval *arg, char *key, uint key_len)
@@ -755,7 +755,7 @@ ZEND_API int add_assoc_null_ex(zval *arg, char *key, uint key_len)
MAKE_STD_ZVAL(tmp);
ZVAL_NULL(tmp);
- return zend_hash_update(Z_ARRVAL_P(arg), key, key_len, (void *) &tmp, sizeof(zval *), NULL);
+ return zend_symtable_update(Z_ARRVAL_P(arg), key, key_len, (void *) &tmp, sizeof(zval *), NULL);
}
ZEND_API int add_assoc_bool_ex(zval *arg, char *key, uint key_len, int b)
@@ -765,7 +765,7 @@ ZEND_API int add_assoc_bool_ex(zval *arg, char *key, uint key_len, int b)
MAKE_STD_ZVAL(tmp);
ZVAL_BOOL(tmp, b);
- return zend_hash_update(Z_ARRVAL_P(arg), key, key_len, (void *) &tmp, sizeof(zval *), NULL);
+ return zend_symtable_update(Z_ARRVAL_P(arg), key, key_len, (void *) &tmp, sizeof(zval *), NULL);
}
ZEND_API int add_assoc_resource_ex(zval *arg, char *key, uint key_len, int r)
@@ -775,7 +775,7 @@ ZEND_API int add_assoc_resource_ex(zval *arg, char *key, uint key_len, int r)
MAKE_STD_ZVAL(tmp);
ZVAL_RESOURCE(tmp, r);
- return zend_hash_update(Z_ARRVAL_P(arg), key, key_len, (void *) &tmp, sizeof(zval *), NULL);
+ return zend_symtable_update(Z_ARRVAL_P(arg), key, key_len, (void *) &tmp, sizeof(zval *), NULL);
}
@@ -786,7 +786,7 @@ ZEND_API int add_assoc_double_ex(zval *arg, char *key, uint key_len, double d)
MAKE_STD_ZVAL(tmp);
ZVAL_DOUBLE(tmp, d);
- return zend_hash_update(Z_ARRVAL_P(arg), key, key_len, (void *) &tmp, sizeof(zval *), NULL);
+ return zend_symtable_update(Z_ARRVAL_P(arg), key, key_len, (void *) &tmp, sizeof(zval *), NULL);
}
@@ -797,7 +797,7 @@ ZEND_API int add_assoc_string_ex(zval *arg, char *key, uint key_len, char *str,
MAKE_STD_ZVAL(tmp);
ZVAL_STRING(tmp, str, duplicate);
- return zend_hash_update(Z_ARRVAL_P(arg), key, key_len, (void *) &tmp, sizeof(zval *), NULL);
+ return zend_symtable_update(Z_ARRVAL_P(arg), key, key_len, (void *) &tmp, sizeof(zval *), NULL);
}
@@ -808,12 +808,12 @@ ZEND_API int add_assoc_stringl_ex(zval *arg, char *key, uint key_len, char *str,
MAKE_STD_ZVAL(tmp);
ZVAL_STRINGL(tmp, str, length, duplicate);
- return zend_hash_update(Z_ARRVAL_P(arg), key, key_len, (void *) &tmp, sizeof(zval *), NULL);
+ return zend_symtable_update(Z_ARRVAL_P(arg), key, key_len, (void *) &tmp, sizeof(zval *), NULL);
}
ZEND_API int add_assoc_zval_ex(zval *arg, char *key, uint key_len, zval *value)
{
- return zend_hash_update(Z_ARRVAL_P(arg), key, key_len, (void *) &value, sizeof(zval *), NULL);
+ return zend_symtable_update(Z_ARRVAL_P(arg), key, key_len, (void *) &value, sizeof(zval *), NULL);
}
@@ -989,7 +989,7 @@ ZEND_API int add_get_assoc_string_ex(zval *arg, char *key, uint key_len, char *s
MAKE_STD_ZVAL(tmp);
ZVAL_STRING(tmp, str, duplicate);
- return zend_hash_update(Z_ARRVAL_P(arg), key, key_len, (void *) &tmp, sizeof(zval *), dest);
+ return zend_symtable_update(Z_ARRVAL_P(arg), key, key_len, (void *) &tmp, sizeof(zval *), dest);
}
@@ -1000,7 +1000,7 @@ ZEND_API int add_get_assoc_stringl_ex(zval *arg, char *key, uint key_len, char *
MAKE_STD_ZVAL(tmp);
ZVAL_STRINGL(tmp, str, length, duplicate);
- return zend_hash_update(Z_ARRVAL_P(arg), key, key_len, (void *) &tmp, sizeof(zval *), dest);
+ return zend_symtable_update(Z_ARRVAL_P(arg), key, key_len, (void *) &tmp, sizeof(zval *), dest);
}
diff --git a/ext/standard/tests/array/bug24766.phpt b/ext/standard/tests/array/bug24766.phpt
index 89434c1939..d6f82f3b16 100644
--- a/ext/standard/tests/array/bug24766.phpt
+++ b/ext/standard/tests/array/bug24766.phpt
@@ -5,15 +5,16 @@ Bug #24766 (strange result array from unpack)
error_reporting(E_ALL);
-$a=unpack('C2', "\0224V");
-debug_zval_dump($a);
-$k=array_keys($a);
-debug_zval_dump($k);
-
+$a = unpack('C2', "\0224V");
+$b = array(1 => 18, 2 => 52);
+debug_zval_dump($a, $b);
+$k = array_keys($a);
+$l = array_keys($b);
+debug_zval_dump($k, $l);
$i=$k[0];
-
-echo $a[$i],"\n";
-
+var_dump($a[$i]);
+$i=$l[0];
+var_dump($b[$i]);
?>
--EXPECT--
array(2) refcount(2){
@@ -23,9 +24,22 @@ array(2) refcount(2){
long(52) refcount(1)
}
array(2) refcount(2){
+ [1]=>
+ long(18) refcount(1)
+ [2]=>
+ long(52) refcount(1)
+}
+array(2) refcount(2){
+ [0]=>
+ long(1) refcount(1)
+ [1]=>
+ long(2) refcount(1)
+}
+array(2) refcount(2){
[0]=>
long(1) refcount(1)
[1]=>
long(2) refcount(1)
}
-18
+int(18)
+int(18)