@@ -53,7 +53,6 @@ static PHP_GINIT_FUNCTION(spl)
53
53
{
54
54
spl_globals -> autoload_extensions = NULL ;
55
55
spl_globals -> autoload_functions = NULL ;
56
- spl_globals -> autoload_running = 0 ;
57
56
}
58
57
/* }}} */
59
58
@@ -405,9 +404,6 @@ static zend_class_entry *spl_perform_autoload(zend_string *class_name, zend_stri
405
404
zval retval ;
406
405
zend_string * func_name ;
407
406
zend_class_entry * called_scope = zend_get_called_scope (EG (current_execute_data ));
408
- int l_autoload_running = SPL_G (autoload_running );
409
-
410
- SPL_G (autoload_running ) = 1 ;
411
407
412
408
fci .size = sizeof (fci );
413
409
fci .retval = & retval ;
@@ -418,6 +414,8 @@ static zend_class_entry *spl_perform_autoload(zend_string *class_name, zend_stri
418
414
419
415
ZVAL_UNDEF (& fci .function_name ); /* Unused */
420
416
417
+ /* We don't use ZEND_HASH_FOREACH here,
418
+ * because autoloaders may be added/removed during autoloading. */
421
419
zend_hash_internal_pointer_reset_ex (SPL_G (autoload_functions ), & pos );
422
420
while (zend_hash_get_current_key_ex (SPL_G (autoload_functions ), & func_name , & num_idx , & pos ) == HASH_KEY_IS_STRING ) {
423
421
autoload_func_info * alfi =
@@ -455,13 +453,11 @@ static zend_class_entry *spl_perform_autoload(zend_string *class_name, zend_stri
455
453
456
454
zend_class_entry * ce = zend_hash_find_ptr (EG (class_table ), lc_name );
457
455
if (ce ) {
458
- SPL_G (autoload_running ) = l_autoload_running ;
459
456
return ce ;
460
457
}
461
458
462
459
zend_hash_move_forward_ex (SPL_G (autoload_functions ), & pos );
463
460
}
464
- SPL_G (autoload_running ) = l_autoload_running ;
465
461
return NULL ;
466
462
}
467
463
@@ -661,14 +657,8 @@ PHP_FUNCTION(spl_autoload_unregister)
661
657
662
658
if (SPL_G (autoload_functions )) {
663
659
if (zend_string_equals_literal (lc_name , "spl_autoload_call" )) {
664
- /* remove all */
665
- if (!SPL_G (autoload_running )) {
666
- zend_hash_destroy (SPL_G (autoload_functions ));
667
- FREE_HASHTABLE (SPL_G (autoload_functions ));
668
- SPL_G (autoload_functions ) = NULL ;
669
- } else {
670
- zend_hash_clean (SPL_G (autoload_functions ));
671
- }
660
+ /* Don't destroy the hash table, as we might be iterating over it right now. */
661
+ zend_hash_clean (SPL_G (autoload_functions ));
672
662
success = SUCCESS ;
673
663
} else {
674
664
/* remove specific */
0 commit comments