php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29954 array_reduce crashes
Submitted: 2004-09-02 16:24 UTC Modified: 2004-11-28 18:06 UTC
From: tomas_matousek at hotmail dot com Assigned:
Status: Closed Package: Reproducible crash
PHP Version: 5.0.1 OS: WinXP
Private report: No CVE-ID: None
 [2004-09-02 16:24 UTC] tomas_matousek at hotmail dot com
Description:
------------
array_reduce function crashes PHP in the following case

Reproduce code:
---------------
function &t(&$a, &$b)
{
  static $o = 1;
  
  $a[$b] = $o;
  $b = $o;
  
  $o++;
  
  return $a;
}

$array0 = array("a", "b", "c", "d", "e"); 
$array1 = array();
print_r(array_reduce($array0,"t",$array1)); 
print_r($array0);
print_r($array1);


Expected result:
----------------
Array
(
  [a] => 1
  [b] => 2
  [c] => 3
  [d] => 4
  [e] => 5
)
Array
(
  [0] => 1
  [1] => 2
  [2] => 3
  [3] => 4
  [4] => 5
)
Array
(
  [a] => 1
  [b] => 2
  [c] => 3
  [d] => 4
  [e] => 5
)

Actual result:
--------------
crash

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-09-02 16:56 UTC] tomas_matousek at hotmail dot com
Errata:
$array1 should be empty when printed out
 [2004-11-28 18:06 UTC] tony2001@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC