summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2005-01-18 10:38:04 +0000
committerDmitry Stogov <dmitry@php.net>2005-01-18 10:38:04 +0000
commitea6ea21939262a54b6d6cfc32f49d70df0972288 (patch)
treec32e4aea8ec9582b4463cd49f3435b387c650f47
parent5c98efddae002a73b3e78fdb5368e405b365ae12 (diff)
downloadphp-git-ea6ea21939262a54b6d6cfc32f49d70df0972288.tar.gz
Fixed bug #31190 (exceptions in call_user_func_array())
-rw-r--r--ext/standard/basic_functions.c6
-rw-r--r--ext/standard/tests/general_functions/bug31190.phpt26
2 files changed, 30 insertions, 2 deletions
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
index 3cc78df76f..1f3987b1c8 100644
--- a/ext/standard/basic_functions.c
+++ b/ext/standard/basic_functions.c
@@ -2085,8 +2085,10 @@ PHP_FUNCTION(call_user_func_array)
func_params = NULL;
}
- 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
index 0000000000..8fdf8eea75
--- /dev/null
+++ b/ext/standard/tests/general_functions/bug31190.phpt
@@ -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!
+