changeset 3741:0f9b2d285bfc

fix segfault, the bug has been introduced in r3738
author Igor Sysoev <igor@sysoev.ru>
date Tue, 03 Aug 2010 18:27:56 +0000
parents fe2688c9e9bd
children 01691af60f94
files src/http/modules/ngx_http_geoip_module.c
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/http/modules/ngx_http_geoip_module.c
+++ b/src/http/modules/ngx_http_geoip_module.c
@@ -274,6 +274,9 @@ ngx_http_geoip_region_name_variable(ngx_
     }
 
     val = GeoIP_region_name_by_code(gr->country_code, gr->region);
+    if (val == NULL) {
+        goto no_value;
+    }
 
     len = ngx_strlen(val);
     v->data = ngx_pnalloc(r->pool, len);
@@ -294,6 +297,10 @@ ngx_http_geoip_region_name_variable(ngx_
 
     return NGX_OK;
 
+no_value:
+
+    GeoIPRecord_delete(gr);
+
 not_found:
 
     v->not_found = 1;