jani Thu, 10 Sep 2009 16:19:42 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=288246
Log: - Simplified a bit and fixed possible memory corruption and definate leak. Changed paths: U php/php-src/branches/PHP_5_3/main/fopen_wrappers.c U php/php-src/branches/PHP_5_3/sapi/cgi/cgi_main.c U php/php-src/trunk/main/fopen_wrappers.c U php/php-src/trunk/sapi/cgi/cgi_main.c Modified: php/php-src/branches/PHP_5_3/main/fopen_wrappers.c =================================================================== --- php/php-src/branches/PHP_5_3/main/fopen_wrappers.c 2009-09-10 15:05:49 UTC (rev 288245) +++ php/php-src/branches/PHP_5_3/main/fopen_wrappers.c 2009-09-10 16:19:42 UTC (rev 288246) @@ -485,6 +485,7 @@ file_handle->opened_path = expand_filepath(filename, NULL TSRMLS_CC); + STR_FREE(SG(request_info).path_translated); /* for same reason as above */ SG(request_info).path_translated = filename; file_handle->filename = SG(request_info).path_translated; Modified: php/php-src/branches/PHP_5_3/sapi/cgi/cgi_main.c =================================================================== --- php/php-src/branches/PHP_5_3/sapi/cgi/cgi_main.c 2009-09-10 15:05:49 UTC (rev 288245) +++ php/php-src/branches/PHP_5_3/sapi/cgi/cgi_main.c 2009-09-10 16:19:42 UTC (rev 288246) @@ -1280,9 +1280,6 @@ if (pt) { efree(pt); } - if (is_valid_path(script_path_translated)) { - SG(request_info).path_translated = estrdup(script_path_translated); - } } else { /* make sure path_info/translated are empty */ if (!orig_script_filename || @@ -1311,9 +1308,6 @@ } else { SG(request_info).request_uri = env_script_name; } - if (is_valid_path(script_path_translated)) { - SG(request_info).path_translated = estrdup(script_path_translated); - } free(real_path); } } else { @@ -1326,11 +1320,12 @@ if (!CGIG(discard_path) && env_path_translated) { script_path_translated = env_path_translated; } - if (is_valid_path(script_path_translated)) { - SG(request_info).path_translated = estrdup(script_path_translated); - } } + if (is_valid_path(script_path_translated)) { + SG(request_info).path_translated = estrdup(script_path_translated); + } + SG(request_info).request_method = sapi_cgibin_getenv("REQUEST_METHOD", sizeof("REQUEST_METHOD")-1 TSRMLS_CC); /* FIXME - Work out proto_num here */ SG(request_info).query_string = sapi_cgibin_getenv("QUERY_STRING", sizeof("QUERY_STRING")-1 TSRMLS_CC); @@ -2131,26 +2126,14 @@ fastcgi_request_done: { - char *path_translated; + STR_FREE(SG(request_info).path_translated); - /* Go through this trouble so that the memory manager doesn't warn - * about SG(request_info).path_translated leaking - */ - if (SG(request_info).path_translated) { - path_translated = strdup(SG(request_info).path_translated); - STR_FREE(SG(request_info).path_translated); - SG(request_info).path_translated = path_translated; - } - php_request_shutdown((void *) 0); + if (exit_status == 0) { exit_status = EG(exit_status); } - if (SG(request_info).path_translated) { - free(SG(request_info).path_translated); - SG(request_info).path_translated = NULL; - } if (free_query_string && SG(request_info).query_string) { free(SG(request_info).query_string); SG(request_info).query_string = NULL; Modified: php/php-src/trunk/main/fopen_wrappers.c =================================================================== --- php/php-src/trunk/main/fopen_wrappers.c 2009-09-10 15:05:49 UTC (rev 288245) +++ php/php-src/trunk/main/fopen_wrappers.c 2009-09-10 16:19:42 UTC (rev 288246) @@ -437,6 +437,7 @@ file_handle->opened_path = expand_filepath(filename, NULL TSRMLS_CC); + STR_FREE(SG(request_info).path_translated); /* for same reason as above */ SG(request_info).path_translated = filename; file_handle->filename = SG(request_info).path_translated; Modified: php/php-src/trunk/sapi/cgi/cgi_main.c =================================================================== --- php/php-src/trunk/sapi/cgi/cgi_main.c 2009-09-10 15:05:49 UTC (rev 288245) +++ php/php-src/trunk/sapi/cgi/cgi_main.c 2009-09-10 16:19:42 UTC (rev 288246) @@ -1277,9 +1277,6 @@ if (pt) { efree(pt); } - if (is_valid_path(script_path_translated)) { - SG(request_info).path_translated = estrdup(script_path_translated); - } } else { /* make sure path_info/translated are empty */ if (!orig_script_filename || @@ -1308,9 +1305,6 @@ } else { SG(request_info).request_uri = env_script_name; } - if (is_valid_path(script_path_translated)) { - SG(request_info).path_translated = estrdup(script_path_translated); - } free(real_path); } } else { @@ -1323,11 +1317,12 @@ if (!CGIG(discard_path) && env_path_translated) { script_path_translated = env_path_translated; } - if (is_valid_path(script_path_translated)) { - SG(request_info).path_translated = estrdup(script_path_translated); - } } + if (is_valid_path(script_path_translated)) { + SG(request_info).path_translated = estrdup(script_path_translated); + } + SG(request_info).request_method = sapi_cgibin_getenv("REQUEST_METHOD", sizeof("REQUEST_METHOD")-1 TSRMLS_CC); /* FIXME - Work out proto_num here */ SG(request_info).query_string = sapi_cgibin_getenv("QUERY_STRING", sizeof("QUERY_STRING")-1 TSRMLS_CC); @@ -2125,26 +2120,14 @@ fastcgi_request_done: { - char *path_translated; + STR_FREE(SG(request_info).path_translated); - /* Go through this trouble so that the memory manager doesn't warn - * about SG(request_info).path_translated leaking - */ - if (SG(request_info).path_translated) { - path_translated = strdup(SG(request_info).path_translated); - STR_FREE(SG(request_info).path_translated); - SG(request_info).path_translated = path_translated; - } - php_request_shutdown((void *) 0); + if (exit_status == 0) { exit_status = EG(exit_status); } - if (SG(request_info).path_translated) { - free(SG(request_info).path_translated); - SG(request_info).path_translated = NULL; - } if (free_query_string && SG(request_info).query_string) { free(SG(request_info).query_string); SG(request_info).query_string = NULL;
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php