mirror of
https://github.com/php/php-src.git
synced 2024-09-22 02:17:32 +00:00
Fixed bug #24766 (strange result array from unpack())
This commit is contained in:
parent
149f786025
commit
4859431fc1
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
18
|
||||
array(2) refcount(2){
|
||||
[0]=>
|
||||
long(1) refcount(1)
|
||||
[1]=>
|
||||
long(2) refcount(1)
|
||||
}
|
||||
int(18)
|
||||
int(18)
|
||||
|
Loading…
Reference in New Issue
Block a user