php.net |  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: a at b dot c dot de
New email:
PHP Version: OS:

 

 [2005-01-27 13:06 UTC] a at b dot c dot de
Description:
------------
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.


Patches

Pull Requests

History

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] stas@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: Fri Nov 22 06:01:30 2024 UTC