]> granicus.if.org Git - php/commitdiff
(php_hash_environment)
authorAndrei Zmievski <andrei@php.net>
Sat, 26 Feb 2000 21:20:38 +0000 (21:20 +0000)
committerAndrei Zmievski <andrei@php.net>
Sat, 26 Feb 2000 21:20:38 +0000 (21:20 +0000)
Fixed a bunch of memory leaks from the recent HTTP_*_VARS[] protection
patch.

main/main.c

index 511e6db4943998803cc99ea9ba4dc1781af51206..5f1737893790f10b35c47ef07f390a2339cb3228 100644 (file)
@@ -947,6 +947,8 @@ static int php_hash_environment(ELS_D SLS_DC PLS_DC)
        unsigned char _gpc_flags[3] = {0,0,0};
        zend_bool have_variables_order;
 
+       PG(http_globals).post = PG(http_globals).get = PG(http_globals).cookie = PG(http_globals).server = PG(http_globals).environment = PG(http_globals).post_files = NULL;
+
        if (PG(variables_order)) {
                p = PG(variables_order);
                have_variables_order=1;
@@ -956,8 +958,6 @@ static int php_hash_environment(ELS_D SLS_DC PLS_DC)
                php_import_environment_variables(ELS_C PLS_CC);
        }
 
-       PG(http_globals).post = PG(http_globals).get = PG(http_globals).cookie = PG(http_globals).server = PG(http_globals).environment = PG(http_globals).post_files = NULL;
-
        while(*p) {
                switch(*p++) {
                        case 'p':
@@ -991,13 +991,15 @@ static int php_hash_environment(ELS_D SLS_DC PLS_DC)
                                break;
                        case 's':
                        case 'S':
-                               if (sapi_module.register_server_variables) {
-                                       php_register_server_variables(ELS_C SLS_CC PLS_CC);
-                               }
+                               php_register_server_variables(ELS_C SLS_CC PLS_CC);
                                break;
                }
        }
 
+       if (!have_variables_order) {
+               php_register_server_variables(ELS_C SLS_CC PLS_CC);
+       }
+
        if (PG(http_globals).post) {
                zend_hash_add_ptr(&EG(symbol_table), "HTTP_POST_VARS", sizeof("HTTP_POST_VARS"), PG(http_globals).post, sizeof(zval *), NULL);
        }
@@ -1017,10 +1019,6 @@ static int php_hash_environment(ELS_D SLS_DC PLS_DC)
                zend_hash_add_ptr(&EG(symbol_table), "HTTP_POST_FILES", sizeof("HTTP_POST_FILES"), PG(http_globals).post_files, sizeof(zval *),NULL);
        }
 
-       if (!have_variables_order) {
-               php_register_server_variables(ELS_C SLS_CC PLS_CC);
-       }
-
        return SUCCESS;
 }