]> git.kaiwu.me - nginx.git/commitdiff
fix segfault, the bug has been introduced in r3738
authorIgor Sysoev <igor@sysoev.ru>
Tue, 3 Aug 2010 18:27:56 +0000 (18:27 +0000)
committerIgor Sysoev <igor@sysoev.ru>
Tue, 3 Aug 2010 18:27:56 +0000 (18:27 +0000)
src/http/modules/ngx_http_geoip_module.c

index e248d01b0f0db4ae7804549490b20db97ea57288..51e20e7517a9659e1ceb0cd4b3cc95a772ae1323 100644 (file)
@@ -274,6 +274,9 @@ ngx_http_geoip_region_name_variable(ngx_http_request_t *r,
     }
 
     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_http_request_t *r,
 
     return NGX_OK;
 
+no_value:
+
+    GeoIPRecord_delete(gr);
+
 not_found:
 
     v->not_found = 1;