]> granicus.if.org Git - php/commitdiff
New autoload protection schema was implemented (Using HashTable instead of boolean...
authorDmitry Stogov <dmitry@php.net>
Wed, 24 Mar 2004 14:30:59 +0000 (14:30 +0000)
committerDmitry Stogov <dmitry@php.net>
Wed, 24 Mar 2004 14:30:59 +0000 (14:30 +0000)
Zend/zend.c
Zend/zend_execute_API.c
Zend/zend_globals.h

index b21a2cff3aa8989ed43bf716cab53c2acc29ded7..20f109c1a54906a34216906561d3036664fe7840 100644 (file)
@@ -467,7 +467,7 @@ static void executor_globals_ctor(zend_executor_globals *executor_globals TSRMLS
        EG(user_error_handler) = NULL;
        EG(user_exception_handler) = NULL;
        EG(in_execution) = 0;
-       EG(in_autoload) = 0;
+       EG(in_autoload) = NULL;
        EG(current_execute_data) = NULL;
 }
 
index 9dcd2dbdec44187a555fa4903b2c6fb63e6965f8..03df2ca548a75d1e239480459564c50d833ddc64 100644 (file)
@@ -137,7 +137,7 @@ void init_executor(TSRMLS_D)
        EG(class_table) = CG(class_table);
 
        EG(in_execution) = 0;
-       EG(in_autoload) = 0;
+       EG(in_autoload) = NULL;
 
        zend_ptr_stack_init(&EG(argument_stack));
        zend_ptr_stack_push(&EG(argument_stack), (void *) NULL);
@@ -293,6 +293,10 @@ void shutdown_executor(TSRMLS_D)
                zend_ptr_stack_destroy(&EG(user_error_handlers));
                zend_ptr_stack_destroy(&EG(user_exception_handlers));
                zend_objects_store_destroy(&EG(objects_store));
+               if (EG(in_autoload)) {
+                       zend_hash_destroy(EG(in_autoload));
+                       efree(EG(in_autoload));
+               }
        } zend_end_try();
 }
 
@@ -879,7 +883,8 @@ ZEND_API int zend_lookup_class(char *name, int name_length, zend_class_entry ***
        int retval;
        char *lc_name;
        zval *exception;
-
+       char dummy = 1;
+       
        lc_name = do_alloca(name_length + 1);
        zend_str_tolower_copy(lc_name, name, name_length);
 
@@ -888,11 +893,15 @@ ZEND_API int zend_lookup_class(char *name, int name_length, zend_class_entry ***
                return SUCCESS;
        }
 
-       if (EG(in_autoload)) {
+       if (EG(in_autoload) == NULL) {
+               EG(in_autoload) = emalloc(sizeof(HashTable));
+               zend_hash_init(EG(in_autoload), 0, NULL, NULL, 0);      
+       }
+       
+       if (zend_hash_add(EG(in_autoload), lc_name, name_length+1, (void**)&dummy, sizeof(char), NULL) == FAILURE) {
                free_alloca(lc_name);
                return FAILURE;
        }
-       EG(in_autoload) = 1;
 
        ZVAL_STRINGL(&autoload_function, "__autoload", sizeof("__autoload")-1,  0);
 
@@ -905,7 +914,7 @@ ZEND_API int zend_lookup_class(char *name, int name_length, zend_class_entry ***
        EG(exception) = NULL;
        retval = call_user_function_ex(EG(function_table), NULL, &autoload_function, &retval_ptr, 1, args, 0, NULL TSRMLS_CC);
 
-       EG(in_autoload) = 0;
+       zend_hash_del(EG(in_autoload), lc_name, name_length+1);
 
        if (retval == FAILURE) {
                EG(exception) = exception;
@@ -1229,7 +1238,6 @@ void zend_unset_timeout(TSRMLS_D)
 zend_class_entry *zend_fetch_class(char *class_name, uint class_name_len, int fetch_type TSRMLS_DC)
 {
        zend_class_entry **pce;
-       zend_bool in_autoload;
 
 check_fetch_type:
        switch (fetch_type) {
@@ -1255,13 +1263,9 @@ check_fetch_type:
                        break;
        }
 
-       in_autoload = EG(in_autoload);
-       EG(in_autoload) = 0;
        if (zend_lookup_class(class_name, class_name_len, &pce TSRMLS_CC)==FAILURE) {
-               EG(in_autoload) = in_autoload;
                zend_error(E_ERROR, "Class '%s' not found", class_name);
        }
-       EG(in_autoload) = in_autoload;
        return *pce;
 }
 
index ae38ffb7db910280dd4b7ad7b673c989b3e32d8f..0668c0481ce358f72848c034531767170b997bba 100644 (file)
@@ -190,7 +190,7 @@ struct _zend_executor_globals {
        int ticks_count;
 
        zend_bool in_execution;
-       zend_bool in_autoload;
+       HashTable *in_autoload;
        zend_bool bailout_set;
        zend_bool full_tables_cleanup;
        zend_bool ze1_compatibility_mode;