mattwil Sun Jun 7 19:28:15 2009 UTC
Added files: (Branch: PHP_5_3)
/ZendEngine2/tests bug47836.phpt
Modified files:
/ZendEngine2 zend_hash.c
/php-src/ext/standard/tests/array array_push_error2.phpt
Log:
MFH: Fixed bug #47836 (array operator [] inconsistency when the array has
PHP_INT_MAX index value)
Also simplified related array_push() test
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_hash.c?r1=1.121.2.4.2.8.2.8&r2=1.121.2.4.2.8.2.9&diff_format=u
Index: ZendEngine2/zend_hash.c
diff -u ZendEngine2/zend_hash.c:1.121.2.4.2.8.2.8
ZendEngine2/zend_hash.c:1.121.2.4.2.8.2.9
--- ZendEngine2/zend_hash.c:1.121.2.4.2.8.2.8 Wed Dec 31 11:15:32 2008
+++ ZendEngine2/zend_hash.c Sun Jun 7 19:28:15 2009
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_hash.c,v 1.121.2.4.2.8.2.8 2008/12/31 11:15:32 sebastian Exp $ */
+/* $Id: zend_hash.c,v 1.121.2.4.2.8.2.9 2009/06/07 19:28:15 mattwil Exp $ */
#include "zend.h"
@@ -376,7 +376,7 @@
UPDATE_DATA(ht, p, pData, nDataSize);
HANDLE_UNBLOCK_INTERRUPTIONS();
if ((long)h >= (long)ht->nNextFreeElement) {
- ht->nNextFreeElement = h + 1;
+ ht->nNextFreeElement = h < LONG_MAX ? h + 1 :
LONG_MAX;
}
if (pDest) {
*pDest = p->pData;
@@ -404,7 +404,7 @@
HANDLE_UNBLOCK_INTERRUPTIONS();
if ((long)h >= (long)ht->nNextFreeElement) {
- ht->nNextFreeElement = h + 1;
+ ht->nNextFreeElement = h < LONG_MAX ? h + 1 : LONG_MAX;
}
ht->nNumOfElements++;
ZEND_HASH_IF_FULL_DO_RESIZE(ht);
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_push_error2.phpt?r1=1.1.4.5&r2=1.1.4.6&diff_format=u
Index: php-src/ext/standard/tests/array/array_push_error2.phpt
diff -u php-src/ext/standard/tests/array/array_push_error2.phpt:1.1.4.5
php-src/ext/standard/tests/array/array_push_error2.phpt:1.1.4.6
--- php-src/ext/standard/tests/array/array_push_error2.phpt:1.1.4.5 Wed Mar
19 03:15:56 2008
+++ php-src/ext/standard/tests/array/array_push_error2.phpt Sun Jun 7
19:28:15 2009
@@ -1,5 +1,5 @@
--TEST--
-Test array_push() function : error conditions - min and max int values as keys
+Test array_push() function : error conditions - max int value as key
--FILE--
<?php
/* Prototype : int array_push(array $stack, mixed $var [, mixed $...])
@@ -8,42 +8,27 @@
*/
/*
- * Use PHP's minimum and maximum integer values as array keys
+ * Use PHP's maximum integer value as array key
* then try and push new elements onto the array
*/
echo "*** Testing array_push() : error conditions ***\n";
-$array = array(-PHP_INT_MAX => 'min', PHP_INT_MAX => 'max');
+$array = array(PHP_INT_MAX => 'max');
var_dump(array_push($array, 'new'));
var_dump($array);
-var_dump(array_push($array, 'var'));
-var_dump($array);
echo "Done";
?>
--EXPECTF--
*** Testing array_push() : error conditions ***
-int(3)
-array(3) {
- [-%d]=>
- string(3) "min"
- [%d]=>
- string(3) "max"
- [-%d]=>
- 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]=>
- string(3) "min"
+array(1) {
[%d]=>
string(3) "max"
- [-%d]=>
- string(3) "new"
}
Done
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/bug47836.phpt?view=markup&rev=1.1
Index: ZendEngine2/tests/bug47836.phpt
+++ ZendEngine2/tests/bug47836.phpt
--TEST--
Bug #47836 (array operator [] inconsistency when the array has PHP_INT_MAX
index value)
--FILE--
<?php
$arr[PHP_INT_MAX] = 1;
$arr[] = 2;
var_dump($arr);
?>
--EXPECTF--
Warning: Cannot add element to the array as the next element is already
occupied in %s on line 4
array(1) {
[%d]=>
int(1)
}
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php