From 16e9d74f078c48eb62afc97a29fa30d1969cc7fd Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 27 Apr 2020 16:22:03 +0200 Subject: [PATCH] Fixed bug #79432 --- ext/spl/php_spl.c | 14 ++++++++------ ext/spl/tests/bug79432.phpt | 14 ++++++++++++++ 2 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 ext/spl/tests/bug79432.phpt diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c index 759218e802..11fec69072 100644 --- a/ext/spl/php_spl.c +++ b/ext/spl/php_spl.c @@ -393,14 +393,16 @@ static void autoload_func_info_dtor(zval *element) Try all registered autoload function to load the requested class */ PHP_FUNCTION(spl_autoload_call) { - zval *class_name, retval; - zend_string *lc_name, *func_name; + zend_string *class_name, *lc_name, *func_name; autoload_func_info *alfi; + zval retval, params[1]; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &class_name) == FAILURE || Z_TYPE_P(class_name) != IS_STRING) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &class_name) == FAILURE) { RETURN_THROWS(); } + ZVAL_STR(¶ms[0], class_name); + if (SPL_G(autoload_functions)) { HashPosition pos; zend_ulong num_idx; @@ -411,12 +413,12 @@ PHP_FUNCTION(spl_autoload_call) int l_autoload_running = SPL_G(autoload_running); SPL_G(autoload_running) = 1; - lc_name = zend_string_tolower(Z_STR_P(class_name)); + lc_name = zend_string_tolower(class_name); fci.size = sizeof(fci); fci.retval = &retval; fci.param_count = 1; - fci.params = class_name; + fci.params = params; fci.no_separation = 1; ZVAL_UNDEF(&fci.function_name); /* Unused */ @@ -474,7 +476,7 @@ PHP_FUNCTION(spl_autoload_call) ZVAL_UNDEF(&fcall_info.function_name); fcall_info.retval = &retval; fcall_info.param_count = 1; - fcall_info.params = class_name; + fcall_info.params = params; fcall_info.object = NULL; fcall_info.no_separation = 1; diff --git a/ext/spl/tests/bug79432.phpt b/ext/spl/tests/bug79432.phpt new file mode 100644 index 0000000000..cce017cb63 --- /dev/null +++ b/ext/spl/tests/bug79432.phpt @@ -0,0 +1,14 @@ +--TEST-- +Bug #79432 (spl_autoload_call() with non-string argument violates assertion) +--FILE-- +getMessage(), "\n"; +} + +?> +--EXPECT-- +spl_autoload_call(): Argument #1 ($class_name) must be of type string, array given -- 2.50.1