]> granicus.if.org Git - php/commitdiff
Fixed bug #31190 (iexceptions in call_user_func_array())
authorDmitry Stogov <dmitry@php.net>
Tue, 18 Jan 2005 10:33:50 +0000 (10:33 +0000)
committerDmitry Stogov <dmitry@php.net>
Tue, 18 Jan 2005 10:33:50 +0000 (10:33 +0000)
NEWS
ext/standard/basic_functions.c
ext/standard/tests/general_functions/bug31190.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 58540a4038dbd1f24fc9aa4487ace061de887d40..77ad05311a1a39ad1b9143fa4dabb9f97330ccf1 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,8 @@ PHP                                                                        NEWS
 - Fixed bug #31396 (compile fails with gd 2.0.33 without freetype). (Jani)
 - Fixed bug #31371 (highlight_file() trims new line after heredoc). (Ilia)
 - Fixed bug #31361 (simplexml/domxml segfault when adding node twice). (Rob)
+- Fixed bug #31190 (call_user_func_array(), exceptions, and the patch).
+  (phpbugs at domain51 dot net, Dmitry)
 - Fixed bug #31142 (imap_mail_compose() fails to generate correct output). (Ilia)
 - Fixed bug #31139 (XML Parser Functions seem to drop &amp; when parsing). (Rob)
 - Fixed bug #31111 (Compile failure of zend_strtod.c). (Derick)
index 68cbbe96a19f1d124b107fe905514ade5c41d31f..9c67d7d95c0c77b43d4054a8ab80c05c86545b54 100644 (file)
@@ -1993,8 +1993,10 @@ PHP_FUNCTION(call_user_func_array)
                current++;
        }
 
-       if (call_user_function_ex(EG(function_table), NULL, *func, &retval_ptr, count, func_params, 0, NULL TSRMLS_CC) == SUCCESS && retval_ptr) {
-               COPY_PZVAL_TO_ZVAL(*return_value, retval_ptr);
+       if (call_user_function_ex(EG(function_table), NULL, *func, &retval_ptr, count, func_params, 0, NULL TSRMLS_CC) == SUCCESS) {
+               if (retval_ptr) {
+                       COPY_PZVAL_TO_ZVAL(*return_value, retval_ptr);
+               }
        } else {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to call %s()", name);
        }
diff --git a/ext/standard/tests/general_functions/bug31190.phpt b/ext/standard/tests/general_functions/bug31190.phpt
new file mode 100644 (file)
index 0000000..8fdf8ee
--- /dev/null
@@ -0,0 +1,26 @@
+--TEST--
+bug #31190 (exception in call_user_func_array())
+--FILE--
+<?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();
+}
+?>
+--EXPECT--
+Hello World!
+Hello World!
+