diff src/http/modules/ngx_http_geoip_module.c @ 594:3436cf38d59e NGINX_0_8_49

nginx 0.8.49 *) Feature: the "image_filter_jpeg_quality" directive supports variables. *) Bugfix: a segmentation fault might occur in a worker process, if the $geoip_region_name variables was used; the bug had appeared in 0.8.48. *) Bugfix: errors intercepted by error_page were cached only for next request; the bug had appeared in 0.8.48.
author Igor Sysoev <http://sysoev.ru>
date Mon, 09 Aug 2010 00:00:00 +0400
parents 09d5f308901f
children
line wrap: on
line diff
--- a/src/http/modules/ngx_http_geoip_module.c
+++ b/src/http/modules/ngx_http_geoip_module.c
@@ -231,7 +231,6 @@ ngx_http_geoip_city_variable(ngx_http_re
 
     len = ngx_strlen(val);
     v->data = ngx_pnalloc(r->pool, len);
-
     if (v->data == NULL) {
         GeoIPRecord_delete(gr);
         return NGX_ERROR;
@@ -275,11 +274,15 @@ ngx_http_geoip_region_name_variable(ngx_
 
     val = GeoIP_region_name_by_code(gr->country_code, gr->region);
 
+    GeoIPRecord_delete(gr);
+
+    if (val == NULL) {
+        goto not_found;
+    }
+
     len = ngx_strlen(val);
     v->data = ngx_pnalloc(r->pool, len);
-
     if (v->data == NULL) {
-        GeoIPRecord_delete(gr);
         return NGX_ERROR;
     }
 
@@ -290,8 +293,6 @@ ngx_http_geoip_region_name_variable(ngx_
     v->no_cacheable = 0;
     v->not_found = 0;
 
-    GeoIPRecord_delete(gr);
-
     return NGX_OK;
 
 not_found: