diff src/http/modules/ngx_http_fastcgi_module.c @ 284:3dbecd747fbb NGINX_0_5_12

nginx 0.5.12 *) Bugfix: nginx could not be built on platforms different from i386, amd64, sparc и ppc; bug appeared in 0.5.8. *) Bugfix: a segmentation fault might occur in worker process if the temporarily files were used while working with FastCGI server; bug appeared in 0.5.8. *) Bugfix: a segmentation fault might occur in worker process if the $fastcgi_script_name variable was logged. *) Bugfix: ngx_http_perl_module could not be built on Solaris.
author Igor Sysoev <http://sysoev.ru>
date Mon, 12 Feb 2007 00:00:00 +0300
parents c5c2b2883984
children 0b1cc3960e27
line wrap: on
line diff
--- a/src/http/modules/ngx_http_fastcgi_module.c
+++ b/src/http/modules/ngx_http_fastcgi_module.c
@@ -1969,28 +1969,39 @@ ngx_http_fastcgi_script_name_variable(ng
     u_char                       *p;
     ngx_http_fastcgi_loc_conf_t  *flcf;
 
-    v->valid = 1;
-    v->no_cachable = 0;
-    v->not_found = 0;
-
-    flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module);
-
-    if (r->uri.data[r->uri.len - 1] != '/') {
-        v->len = r->uri.len;
-        v->data = r->uri.data;
+    if (r->uri.len) {
+        v->valid = 1;
+        v->no_cachable = 0;
+        v->not_found = 0;
+
+        flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module);
+
+        if (r->uri.data[r->uri.len - 1] != '/') {
+            v->len = r->uri.len;
+            v->data = r->uri.data;
+            return NGX_OK;
+        }
+
+        v->len = r->uri.len + flcf->index.len;
+
+        v->data = ngx_palloc(r->pool, v->len);
+        if (v->data == NULL) {
+            return NGX_ERROR;
+        }
+
+        p = ngx_copy(v->data, r->uri.data, r->uri.len);
+        ngx_memcpy(p, flcf->index.data, flcf->index.len);
+
+    } else {
+        v->len = 0;
+        v->valid = 1;
+        v->no_cachable = 0;
+        v->not_found = 0;
+        v->data = NULL;
+
         return NGX_OK;
     }
 
-    v->len = r->uri.len + flcf->index.len;
-
-    v->data = ngx_palloc(r->pool, v->len);
-    if (v->data == NULL) {
-        return NGX_ERROR;
-    }
-
-    p = ngx_copy(v->data, r->uri.data, r->uri.len);
-    ngx_memcpy(p, flcf->index.data, flcf->index.len);
-
     return NGX_OK;
 }