]> granicus.if.org Git - php/commitdiff
Do the right fix..
authorMoriyoshi Koizumi <moriyoshi@php.net>
Fri, 28 Mar 2003 18:24:02 +0000 (18:24 +0000)
committerMoriyoshi Koizumi <moriyoshi@php.net>
Fri, 28 Mar 2003 18:24:02 +0000 (18:24 +0000)
sapi/cgi/cgi_main.c

index 30962e4b59a2404ec0c5ba130a48e909a20a8869..12bc2348206cdea8a7da1c3c194b3c5225191b73 100644 (file)
@@ -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 {