Skip to content

Commit 16e9d74

Browse files
committed
Fixed bug #79432
1 parent c5f87ee commit 16e9d74

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

ext/spl/php_spl.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -393,14 +393,16 @@ static void autoload_func_info_dtor(zval *element)
393393
Try all registered autoload function to load the requested class */
394394
PHP_FUNCTION(spl_autoload_call)
395395
{
396-
zval *class_name, retval;
397-
zend_string *lc_name, *func_name;
396+
zend_string *class_name, *lc_name, *func_name;
398397
autoload_func_info *alfi;
398+
zval retval, params[1];
399399

400-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &class_name) == FAILURE || Z_TYPE_P(class_name) != IS_STRING) {
400+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &class_name) == FAILURE) {
401401
RETURN_THROWS();
402402
}
403403

404+
ZVAL_STR(&params[0], class_name);
405+
404406
if (SPL_G(autoload_functions)) {
405407
HashPosition pos;
406408
zend_ulong num_idx;
@@ -411,12 +413,12 @@ PHP_FUNCTION(spl_autoload_call)
411413
int l_autoload_running = SPL_G(autoload_running);
412414

413415
SPL_G(autoload_running) = 1;
414-
lc_name = zend_string_tolower(Z_STR_P(class_name));
416+
lc_name = zend_string_tolower(class_name);
415417

416418
fci.size = sizeof(fci);
417419
fci.retval = &retval;
418420
fci.param_count = 1;
419-
fci.params = class_name;
421+
fci.params = params;
420422
fci.no_separation = 1;
421423

422424
ZVAL_UNDEF(&fci.function_name); /* Unused */
@@ -474,7 +476,7 @@ PHP_FUNCTION(spl_autoload_call)
474476
ZVAL_UNDEF(&fcall_info.function_name);
475477
fcall_info.retval = &retval;
476478
fcall_info.param_count = 1;
477-
fcall_info.params = class_name;
479+
fcall_info.params = params;
478480
fcall_info.object = NULL;
479481
fcall_info.no_separation = 1;
480482

ext/spl/tests/bug79432.phpt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
Bug #79432 (spl_autoload_call() with non-string argument violates assertion)
3+
--FILE--
4+
<?php
5+
6+
try {
7+
spl_autoload_call([]);
8+
} catch (TypeError $e) {
9+
echo $e->getMessage(), "\n";
10+
}
11+
12+
?>
13+
--EXPECT--
14+
spl_autoload_call(): Argument #1 ($class_name) must be of type string, array given

0 commit comments

Comments
 (0)