summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sapi/cgi/cgi_main.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c
index 30962e4b59..12bc234820 100644
--- a/sapi/cgi/cgi_main.c
+++ b/sapi/cgi/cgi_main.c
@@ -389,7 +389,10 @@ static char *_sapi_cgibin_putenv(char *name, char *value TSRMLS_DC)
char *buf = NULL;
if (!name) return NULL;
len = strlen(name) + (value?strlen(value):0) + sizeof("=") + 2;
- buf = (char *)emalloc(len);
+ buf = (char *)malloc(len);
+ if (buf == NULL) {
+ return getenv(name);
+ }
if (value) {
snprintf(buf,len-1,"%s=%s", name, value);
} else {
@@ -403,7 +406,7 @@ static char *_sapi_cgibin_putenv(char *name, char *value TSRMLS_DC)
if (!FCGX_IsCGI()) {
FCGX_Request *request = (FCGX_Request *)SG(server_context);
FCGX_PutEnv(request,buf);
- efree(buf);
+ free(buf);
return sapi_cgibin_getenv(name,0 TSRMLS_CC);
}
#endif
@@ -412,11 +415,7 @@ static char *_sapi_cgibin_putenv(char *name, char *value TSRMLS_DC)
this leaks, but it's only cgi anyway, we'll fix
it for 5.0
*/
- if (value)
- putenv(strdup(buf));
- else
- putenv(buf);
- efree(buf);
+ putenv(buf);
return getenv(name);
}
@@ -808,8 +807,8 @@ static void init_request_info(TSRMLS_D)
} else {
/* make sure path_info/translated are empty */
script_path_translated = _sapi_cgibin_putenv("SCRIPT_FILENAME",script_path_translated TSRMLS_CC);
- _sapi_cgibin_putenv("PATH_INFO", "" TSRMLS_CC);
- _sapi_cgibin_putenv("PATH_TRANSLATED", "" TSRMLS_CC);
+ _sapi_cgibin_putenv("PATH_INFO", NULL TSRMLS_CC);
+ _sapi_cgibin_putenv("PATH_TRANSLATED", NULL TSRMLS_CC);
}
SG(request_info).request_uri = sapi_cgibin_getenv("SCRIPT_NAME",0 TSRMLS_CC);
} else {