diff options
-rw-r--r-- | ext/standard/basic_functions.c | 6 | ||||
-rw-r--r-- | ext/standard/tests/general_functions/bug31190.phpt | 26 |
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! + |