php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31190 call_user_func_array(), exceptions, and the patch
Submitted: 2004-12-20 01:45 UTC Modified: 2005-01-18 11:38 UTC
Votes:3
Avg. Score:4.7 ± 0.5
Reproduced:3 of 3 (100.0%)
Same Version:3 (100.0%)
Same OS:3 (100.0%)
From: phpbugs at domain51 dot net Assigned: andi (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5CVS-2004-12-20 (dev) OS: All
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: phpbugs at domain51 dot net
New email:
PHP Version: OS:

 

 [2004-12-20 01:45 UTC] phpbugs at domain51 dot net
Description:
------------
call_user_func_array() uses a compounded if() statement on line 1996 in file ext/standard/basic_functions.c of the current CVS snapshot (200412192330) and v5.0.3 Stable which catches the Exceptions improperly.  call_user_func() does not have this compounded if() statement, and works properly.

To fix the code, change the following if statement:

if (call_user_function_ex(EG(function_table), NULL, *func, &retval_ptr, count, func_params, 0, NULL TSRMLS_CC) == SUCCESS && retval_ptr) {

To: 

if (call_user_function_ex(EG(function_table), params[1], *params[0], &retval_ptr, arg_count-2, params+2, 0, NULL TSRMLS_CC) == SUCCESS) {
  if (retval_ptr) {


NOTE: This is a duplicate of #28934, which has had this same bug fix in it since early September prior to v5.0.2.  I'm opening a new report in hopes that it will bring attention to this known bugfix this will fixed in the CVS and adopted prior the next version of PHP 5.0.x.

Reproduce code:
---------------
<?php

class test {
    function throwException() { throw new Exception("Hello World!\n"); }
}

$array = array(new test(), 'throwException');
try { 
    call_user_func($array, 1, 2);
} catch (Exception $e) {
    echo $e->getMessage();
}

try {
    call_user_func_array($array, array(1, 2));
} catch (Exception $e) {
    echo $e->getMessage();
}

Expected result:
----------------
$ php -f call_user_func.php
Hello World!
Hello World!

Actual result:
--------------
$ php -f call_user_func.php
Hello World!
<br />
<b>Warning</b>:  call_user_func_array() [<a href='function.call-user-func-array'>function.call-user-func-array</a>]: Unable to call test::throwException() in <b>/home/tswicegood/Desktop/BrainDump/phpbin/call_user_func.php</b> on line <b>19</b><br />
Hello World!


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-01-18 11:38 UTC] dmitry@php.net
Fixed in CVS (HEAD and PHP_5_0).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 16:01:33 2024 UTC