#48093 [Opn->Bgs]: Generated index is reset due to integer overflow
| From: | sniper@php.net | Date: | Tue, 28 Apr 2009 07:55:30 +0000 |
| Subject: | #48093 [Opn->Bgs]: Generated index is reset due to integer overflow | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-136435@lists.php.net to get a copy of this message | ||
ID: 48093
Updated by: sniper@php.net
Reported By: Marcel dot Glacki at stud dot fh-swf dot de
-Status: Open
+Status: Bogus
Bug Type: Arrays related
Operating System: *
PHP Version: 5.2.9
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Previous Comments:
------------------------------------------------------------------------
[2009-04-27 23:02:39] Marcel dot Glacki at stud dot fh-swf dot de
Description:
------------
The generated index normally has the highest integer value regarding
all integers it has encountered as indexes before. (And is automatically
increased by +1)
It is possible to reset this index (the internal pointer) not only by
the functions intended to do so (like reset()) but also by increasing it
above integers' max value (integer overflow).
Reproduce code:
---------------
<?php
$max_int = 2147483647; // Max value for integer on a 32-bit system
$arr = array();
$arr[1] = 'one'; // New index: 2
$arr[ $max_int ] = 'two'; // New index: -2147483648
$arr[0] = 'three'; // New index: 1 (already occupied with value 'foo')
$arr[] = 'failure here'; // Warning: Cannot add element to the array
as the next element is already occupied.
?>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=48093&edit=1