|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31720 Invalid object callbacks not caught in array_walk()
Submitted: 2005-01-27 13:06 UTC Modified: 2005-02-02 11:38 UTC
From: a at b dot c dot de Assigned:
Status: Closed Package: Reproducible crash
PHP Version: 5.0.3 OS: Windows XP
Private report: No CVE-ID: None
 [2005-01-27 13:06 UTC] a at b dot c dot de
Using array_walk will crash PHP if a method of an uninstantiated object variable is used in the callback method. Other functions that take variables (at least, usort(), array_map(), array_reduce()) error out instead. There has to be at least one element in the array being walked.

Reproduce code:
$array = array('at least one element');

array_walk($array, array($nonesuchvar,'show'));

Expected result:
PHP 4.3.10's error message for this situation reads:

Warning:  array_walk(): Unable to call Array() - function does not exist in ...

while PHP 5.0.3 also reports a Notice-level message that $nonesuchvar is undefined.

Actual result:
A Notice-level message that $nonesuchvar is undefined, then a Windows core dump.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-01-28 00:27 UTC] a at b dot c dot de
I guess I could point out that when I found this I was trying to find some way to call a certain method of each of the array's elements, i.e. call $child->show() for each $child in $children. If there's a way to do this with array_walk() that doesn't involve additional wrapper functions then it eludes me.
 [2005-02-02 11:38 UTC]
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
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Nov 28 18:03:14 2021 UTC