Mercurial > hg > nginx
diff src/http/modules/ngx_http_geoip_module.c @ 3742:01691af60f94
we can free GeoIPRecord just after GeoIP_region_name_by_code(),
because it returns a statically allocated string
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 03 Aug 2010 18:38:08 +0000 |
parents | 0f9b2d285bfc |
children | 30d4d6187316 |
line wrap: on
line diff
--- a/src/http/modules/ngx_http_geoip_module.c Tue Aug 03 18:27:56 2010 +0000 +++ b/src/http/modules/ngx_http_geoip_module.c Tue Aug 03 18:38:08 2010 +0000 @@ -231,7 +231,6 @@ len = ngx_strlen(val); v->data = ngx_pnalloc(r->pool, len); - if (v->data == NULL) { GeoIPRecord_delete(gr); return NGX_ERROR; @@ -274,15 +273,16 @@ } val = GeoIP_region_name_by_code(gr->country_code, gr->region); + + GeoIPRecord_delete(gr); + if (val == NULL) { - goto no_value; + goto not_found; } len = ngx_strlen(val); v->data = ngx_pnalloc(r->pool, len); - if (v->data == NULL) { - GeoIPRecord_delete(gr); return NGX_ERROR; } @@ -293,14 +293,8 @@ v->no_cacheable = 0; v->not_found = 0; - GeoIPRecord_delete(gr); - return NGX_OK; -no_value: - - GeoIPRecord_delete(gr); - not_found: v->not_found = 1;