--TEST--
Test array_push() function : error conditions - min and max int values as keys
+--SKIPIF--
+<?php
+if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
+?>
--FILE--
<?php
/* Prototype : int array_push(array $stack, mixed $var [, mixed $...])
*** Testing array_push() : error conditions ***
int(3)
array(3) {
- [-%d]=>
+ [-2147483647]=>
string(3) "min"
- [%d]=>
+ [2147483647]=>
string(3) "max"
- [-%d]=>
+ [-2147483648]=>
string(3) "new"
}
Warning: array_push(): Cannot add element to the array as the next element is already occupied in %s on line %d
bool(false)
array(3) {
- [-%d]=>
+ [-2147483647]=>
string(3) "min"
- [%d]=>
+ [2147483647]=>
string(3) "max"
- [-%d]=>
+ [-2147483648]=>
string(3) "new"
}
-Done
\ No newline at end of file
+Done
--- /dev/null
+--TEST--
+Bug #43614 (incorrect processing of numerical string keys of array in arbitrary serialized data)
+--FILE--
+<?php
+
+error_reporting(E_ALL);
+
+var_dump($a = unserialize('a:2:{s:2:"10";i:1;s:2:"01";i:2;}'));
+var_dump($a['10']);
+var_dump($a['01']);
+
+?>
+--EXPECT--
+array(2) {
+ [10]=>
+ int(1)
+ ["01"]=>
+ int(2)
+}
+int(1)
+int(2)
zend_hash_index_update(ht, Z_LVAL_P(key), &data, sizeof(data), NULL);
break;
case IS_STRING:
- if (zend_hash_find(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, (void **)&old_data)==SUCCESS) {
+ if (zend_symtable_find(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, (void **)&old_data)==SUCCESS) {
var_push_dtor(var_hash, old_data);
}
- zend_hash_update(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, &data, sizeof(data), NULL);
+ zend_symtable_update(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, &data, sizeof(data), NULL);
break;
}
zend_hash_index_update(ht, Z_LVAL_P(key), &data, sizeof(data), NULL);
break;
case IS_STRING:
- if (zend_hash_find(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, (void **)&old_data)==SUCCESS) {
+ if (zend_symtable_find(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, (void **)&old_data)==SUCCESS) {
var_push_dtor(var_hash, old_data);
}
- zend_hash_update(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, &data, sizeof(data), NULL);
+ zend_symtable_update(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, &data, sizeof(data), NULL);
break;
}