# HG changeset patch # User Igor Sysoev # Date 1280860688 0 # Node ID 01691af60f94a165a1701b403942ddb6c1ed52be # Parent 0f9b2d285bfc8d6362a97e6838af88481826ee38 we can free GeoIPRecord just after GeoIP_region_name_by_code(), because it returns a statically allocated string diff --git a/src/http/modules/ngx_http_geoip_module.c b/src/http/modules/ngx_http_geoip_module.c --- 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; @@ -274,15 +273,16 @@ 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 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_ 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;