]> granicus.if.org Git - php/commitdiff
Fixed bug #24766 (strange result array from unpack())
authorMoriyoshi Koizumi <moriyoshi@php.net>
Fri, 3 Oct 2003 22:41:43 +0000 (22:41 +0000)
committerMoriyoshi Koizumi <moriyoshi@php.net>
Fri, 3 Oct 2003 22:41:43 +0000 (22:41 +0000)
Zend/zend_API.c
ext/standard/tests/array/bug24766.phpt

index b616b2fca7c128a464afe60ff494c67c424593a1..edba59c2eb2c5d22d999131a7af66955773c98b1 100644 (file)
@@ -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);
 }
 
 
index 89434c1939478a896c0cf6f10ef3a5f7bc8459b4..d6f82f3b16f86de9bc32efc70a882df933da1fd8 100644 (file)
@@ -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){
@@ -22,10 +23,23 @@ array(2) refcount(2){
   [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)