]> git.kaiwu.me - nginx.git/commitdiff
fix segfault if $server_addr failed
authorIgor Sysoev <igor@sysoev.ru>
Fri, 20 Oct 2006 19:07:50 +0000 (19:07 +0000)
committerIgor Sysoev <igor@sysoev.ru>
Fri, 20 Oct 2006 19:07:50 +0000 (19:07 +0000)
src/http/modules/ngx_http_charset_filter_module.c
src/http/modules/ngx_http_map_module.c
src/http/ngx_http_variables.c

index b9c9ade910898a3ee47994dc5743fa3d51a6dc30..cae9bbe53510415f5efadeb753bf852e0a2ddfaf 100644 (file)
@@ -250,6 +250,10 @@ ngx_http_charset_header_filter(ngx_http_request_t *r)
                 vv = ngx_http_get_indexed_variable(r,
                                                charset - NGX_HTTP_CHARSET_VAR);
 
+                if (vv == NULL || vv->not_found) {
+                    return NGX_ERROR;
+                }
+
                 charset = ngx_http_charset_get_charset(charsets, n,
                                                        (ngx_str_t *) vv);
             }
@@ -293,6 +297,10 @@ ngx_http_charset_header_filter(ngx_http_request_t *r)
             vv = ngx_http_get_indexed_variable(r,
                                         source_charset - NGX_HTTP_CHARSET_VAR);
 
+            if (vv == NULL || vv->not_found) {
+                return NGX_ERROR;
+            }
+
             source_charset = ngx_http_charset_get_charset(charsets, n,
                                                           (ngx_str_t *) vv);
         }
index 0a533c0f50e0df600242161586e386d2d820cd77..fb8e8ee6074ac63dc801545e47daa983604d4cf6 100644 (file)
@@ -115,6 +115,11 @@ ngx_http_map_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v,
 
     vv = ngx_http_get_flushed_variable(r, map->index);
 
+    if (vv == NULL || vv->not_found) {
+        *v = *map->default_value;
+        return NGX_OK;
+    }
+
     len = vv->len;
 
     if (len && map->hostnames && vv->data[len - 1] == '.') {
index 12014582943a64cfc253c3f19bee20cdfa198413..48b46f07d1cef519cdb13cb60ed5f603db1b6a8c 100644 (file)
@@ -367,7 +367,7 @@ ngx_http_get_indexed_variable(ngx_http_request_t *r, ngx_uint_t index)
     r->variables[index].valid = 0;
     r->variables[index].not_found = 1;
 
-    return NULL;
+    return &r->variables[index];
 }