diff src/core/nginx.c @ 280:fa73fb2d9427 NGINX_0_5_10

nginx 0.5.10 *) Bugfix: while online executable file upgrade the new master process did not inherit the listening sockets; bug appeared in 0.5.9. *) Bugfix: a segmentation fault might occur in worker process if nginx was built with -O2 optimization; bug appeared in 0.5.1.
author Igor Sysoev <http://sysoev.ru>
date Fri, 26 Jan 2007 00:00:00 +0300
parents 704622b2528a
children fc223117327f
line wrap: on
line diff
--- a/src/core/nginx.c
+++ b/src/core/nginx.c
@@ -423,15 +423,8 @@ ngx_set_environment(ngx_cycle_t *cycle, 
 
     ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
 
-    if (last) {
-        n = *last;
-
-    } else {
-        if (ccf->environment) {
-            return ccf->environment;
-        }
-
-        n = 0;
+    if (last == NULL && ccf->environment) {
+        return ccf->environment;
     }
 
     var = ccf->env.elts;
@@ -453,6 +446,8 @@ ngx_set_environment(ngx_cycle_t *cycle, 
 
 tz_found:
 
+    n = 0;
+
     for (i = 0; i < ccf->env.nelts; i++) {
 
         if (var[i].data[var[i].len] == '=') {
@@ -472,8 +467,8 @@ tz_found:
     }
 
     if (last) {
+        env = ngx_alloc((*last + n + 1) * sizeof(char *), cycle->log);
         *last = n;
-        env = ngx_alloc((n + 1) * sizeof(char *), cycle->log);
 
     } else {
         env = ngx_palloc(cycle->pool, (n + 1) * sizeof(char *));