diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 3cc78df76f4..1f3987b1c8e 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 00000000000..8fdf8eea756 --- /dev/null +++ b/ext/standard/tests/general_functions/bug31190.phpt @@ -0,0 +1,26 @@ +--TEST-- +bug #31190 (exception in call_user_func_array()) +--FILE-- +getMessage(); +} + +try { + call_user_func_array($array, array(1, 2)); +} catch (Exception $e) { + echo $e->getMessage(); +} +?> +--EXPECT-- +Hello World! +Hello World! +