diff options
author | Igor Sysoev <igor@sysoev.ru> | 2010-08-03 18:38:08 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2010-08-03 18:38:08 +0000 |
commit | 541d8c698ac816a603e6959c3cb97445c3374f5a (patch) | |
tree | 7eee731164b599e3783583381287979b60d98c54 /src | |
parent | a999586594747e855ab5fe7299eba6177cd15656 (diff) | |
download | nginx-541d8c698ac816a603e6959c3cb97445c3374f5a.tar.gz nginx-541d8c698ac816a603e6959c3cb97445c3374f5a.zip |
we can free GeoIPRecord just after GeoIP_region_name_by_code(),
because it returns a statically allocated string
Diffstat (limited to 'src')
-rw-r--r-- | src/http/modules/ngx_http_geoip_module.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/src/http/modules/ngx_http_geoip_module.c b/src/http/modules/ngx_http_geoip_module.c index 51e20e751..592314c84 100644 --- 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_request_t *r, 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 @@ ngx_http_geoip_region_name_variable(ngx_http_request_t *r, } 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 @@ ngx_http_geoip_region_name_variable(ngx_http_request_t *r, 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; |