From:             tomas_matousek at hotmail dot com
Operating system: WinXP
PHP version:      5.0.0RC3
PHP Bug Type:     Arrays related
Bug description:  array_slice treats large lengths incorrectly

Description:
------------
If offset + length > MAX_INTEGER then array_slice function returns wrong
results (obviously overflows soume integer in its implementation).


Reproduce code:
---------------
$a = array(0,1,2,3,4,5);

// this is ok:   
print_r(array_slice($a,2,2147483645));

// this is wrong:
print_r(array_slice($a,2,2147483646));


Expected result:
----------------
Array
(
    [0] => 2
    [1] => 3
    [2] => 4
    [3] => 5
)
Array
(
    [0] => 2
    [1] => 3
    [2] => 4
    [3] => 5
)


Actual result:
--------------
Array
(
    [0] => 2
    [1] => 3
    [2] => 4
    [3] => 5
)
Array
(
)

-- 
Edit bug report at http://bugs.php.net/?id=28974&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=28974&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=28974&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=28974&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=28974&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=28974&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=28974&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=28974&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=28974&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=28974&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=28974&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=28974&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=28974&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28974&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=28974&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=28974&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=28974&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=28974&r=float

Reply via email to