mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Fixed bug #75049 (spl_autoload_unregister can't handle spl_autoload_functions results)
This commit is contained in:
parent
afb20f4895
commit
b06f8cb58b
3 changed files with 34 additions and 4 deletions
2
NEWS
2
NEWS
|
@ -46,6 +46,8 @@ PHP NEWS
|
|||
(Laruence)
|
||||
|
||||
- SPL:
|
||||
. Fixed bug #75049 (spl_autoload_unregister can't handle
|
||||
spl_autoload_functions results). (Laruence)
|
||||
. Fixed bug #74669 (Unserialize ArrayIterator broken). (Andrew Nester)
|
||||
. Fixed bug #75015 (Crash in recursive iterator destructors). (Julien)
|
||||
|
||||
|
|
|
@ -536,9 +536,15 @@ PHP_FUNCTION(spl_autoload_register)
|
|||
ZSTR_VAL(lc_name)[ZSTR_LEN(lc_name)] = '\0';
|
||||
} else {
|
||||
ZVAL_UNDEF(&alfi.closure);
|
||||
/* Skip leading \ */
|
||||
if (ZSTR_VAL(func_name)[0] == '\\') {
|
||||
lc_name = zend_string_alloc(ZSTR_LEN(func_name) - 1, 0);
|
||||
zend_str_tolower_copy(ZSTR_VAL(lc_name), ZSTR_VAL(func_name) + 1, ZSTR_LEN(func_name) - 1);
|
||||
} else {
|
||||
lc_name = zend_string_alloc(ZSTR_LEN(func_name), 0);
|
||||
zend_str_tolower_copy(ZSTR_VAL(lc_name), ZSTR_VAL(func_name), ZSTR_LEN(func_name));
|
||||
}
|
||||
}
|
||||
zend_string_release(func_name);
|
||||
|
||||
if (SPL_G(autoload_functions) && zend_hash_exists(SPL_G(autoload_functions), lc_name)) {
|
||||
|
@ -654,10 +660,16 @@ PHP_FUNCTION(spl_autoload_unregister)
|
|||
zend_str_tolower_copy(ZSTR_VAL(lc_name), ZSTR_VAL(func_name), ZSTR_LEN(func_name));
|
||||
memcpy(ZSTR_VAL(lc_name) + ZSTR_LEN(func_name), &Z_OBJ_HANDLE_P(zcallable), sizeof(uint32_t));
|
||||
ZSTR_VAL(lc_name)[ZSTR_LEN(lc_name)] = '\0';
|
||||
} else {
|
||||
/* Skip leading \ */
|
||||
if (ZSTR_VAL(func_name)[0] == '\\') {
|
||||
lc_name = zend_string_alloc(ZSTR_LEN(func_name) - 1, 0);
|
||||
zend_str_tolower_copy(ZSTR_VAL(lc_name), ZSTR_VAL(func_name) + 1, ZSTR_LEN(func_name) - 1);
|
||||
} else {
|
||||
lc_name = zend_string_alloc(ZSTR_LEN(func_name), 0);
|
||||
zend_str_tolower_copy(ZSTR_VAL(lc_name), ZSTR_VAL(func_name), ZSTR_LEN(func_name));
|
||||
}
|
||||
}
|
||||
zend_string_release(func_name);
|
||||
|
||||
if (SPL_G(autoload_functions)) {
|
||||
|
|
16
ext/spl/tests/bug75049.phpt
Normal file
16
ext/spl/tests/bug75049.phpt
Normal file
|
@ -0,0 +1,16 @@
|
|||
--TEST--
|
||||
Bug #75049 (spl_autoload_unregister can't handle spl_autoload_functions results)
|
||||
--FILE--
|
||||
<?php
|
||||
class Auto { public static function loader() {}}
|
||||
$autoloader = '\Auto::loader';
|
||||
|
||||
echo (int)spl_autoload_register($autoloader);
|
||||
echo (int)spl_autoload_unregister($autoloader);
|
||||
echo (int)spl_autoload_register($autoloader);
|
||||
foreach (spl_autoload_functions() as $loader) {
|
||||
echo (int)spl_autoload_unregister($loader);
|
||||
}
|
||||
echo (int)count(spl_autoload_functions());
|
||||
--EXPECTF--
|
||||
11110
|
Loading…
Add table
Add a link
Reference in a new issue