mirror of
https://github.com/nginx/nginx.git
synced 2024-12-22 15:13:28 -06:00
we can free GeoIPRecord just after GeoIP_region_name_by_code(),
because it returns a statically allocated string
This commit is contained in:
parent
a999586594
commit
541d8c698a
@ -231,7 +231,6 @@ ngx_http_geoip_city_variable(ngx_http_request_t *r,
|
|||||||
|
|
||||||
len = ngx_strlen(val);
|
len = ngx_strlen(val);
|
||||||
v->data = ngx_pnalloc(r->pool, len);
|
v->data = ngx_pnalloc(r->pool, len);
|
||||||
|
|
||||||
if (v->data == NULL) {
|
if (v->data == NULL) {
|
||||||
GeoIPRecord_delete(gr);
|
GeoIPRecord_delete(gr);
|
||||||
return NGX_ERROR;
|
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);
|
val = GeoIP_region_name_by_code(gr->country_code, gr->region);
|
||||||
|
|
||||||
|
GeoIPRecord_delete(gr);
|
||||||
|
|
||||||
if (val == NULL) {
|
if (val == NULL) {
|
||||||
goto no_value;
|
goto not_found;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = ngx_strlen(val);
|
len = ngx_strlen(val);
|
||||||
v->data = ngx_pnalloc(r->pool, len);
|
v->data = ngx_pnalloc(r->pool, len);
|
||||||
|
|
||||||
if (v->data == NULL) {
|
if (v->data == NULL) {
|
||||||
GeoIPRecord_delete(gr);
|
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,14 +293,8 @@ ngx_http_geoip_region_name_variable(ngx_http_request_t *r,
|
|||||||
v->no_cacheable = 0;
|
v->no_cacheable = 0;
|
||||||
v->not_found = 0;
|
v->not_found = 0;
|
||||||
|
|
||||||
GeoIPRecord_delete(gr);
|
|
||||||
|
|
||||||
return NGX_OK;
|
return NGX_OK;
|
||||||
|
|
||||||
no_value:
|
|
||||||
|
|
||||||
GeoIPRecord_delete(gr);
|
|
||||||
|
|
||||||
not_found:
|
not_found:
|
||||||
|
|
||||||
v->not_found = 1;
|
v->not_found = 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user