From: Andrei Zmievski Date: Sat, 26 Feb 2000 21:20:38 +0000 (+0000) Subject: (php_hash_environment) X-Git-Tag: PHP-4.0-RC1~384 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=137e1a1379989a6162cdd0db6cc6efadc7a1e5db;p=php (php_hash_environment) Fixed a bunch of memory leaks from the recent HTTP_*_VARS[] protection patch. --- diff --git a/main/main.c b/main/main.c index 511e6db494..5f17378937 100644 --- a/main/main.c +++ b/main/main.c @@ -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; }