summaryrefslogtreecommitdiff
path: root/sapi/cgi/cgi_main.c
diff options
context:
space:
mode:
authorMoriyoshi Koizumi <moriyoshi@php.net>2003-03-28 18:25:01 +0000
committerMoriyoshi Koizumi <moriyoshi@php.net>2003-03-28 18:25:01 +0000
commitc4521dfb2f16305de0804f73432c180df18b5a6c (patch)
tree6d32e74df1f0e8fb951a942877cf5458338fba04 /sapi/cgi/cgi_main.c
parentb7875715ce7973e7710128e809383edcd858e726 (diff)
downloadphp-git-c4521dfb2f16305de0804f73432c180df18b5a6c.tar.gz
MFH(r-1.222): do the right fix..
Diffstat (limited to 'sapi/cgi/cgi_main.c')
-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 f08f57191d..6e02e6a50c 100644
--- a/sapi/cgi/cgi_main.c
+++ b/sapi/cgi/cgi_main.c
@@ -368,7 +368,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 {
@@ -382,7 +385,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
@@ -391,11 +394,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);
}
@@ -787,8 +786,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 {