mirror of
https://github.com/nginx/nginx.git
synced 2025-08-04 21:46:14 +08:00
Merge of r4648, r4649, r4650: memory leak with $geoip_org.
Patch by Denis F. Latypoff (slightly modified).
This commit is contained in:
parent
049447b267
commit
0b23391686
@ -28,7 +28,7 @@ typedef struct {
|
|||||||
} ngx_http_geoip_var_t;
|
} ngx_http_geoip_var_t;
|
||||||
|
|
||||||
|
|
||||||
typedef const char *(*ngx_http_geoip_variable_handler_pt)(GeoIP *, u_long addr);
|
typedef char *(*ngx_http_geoip_variable_handler_pt)(GeoIP *, u_long addr);
|
||||||
|
|
||||||
static u_long ngx_http_geoip_addr(ngx_http_request_t *r,
|
static u_long ngx_http_geoip_addr(ngx_http_request_t *r,
|
||||||
ngx_http_geoip_conf_t *gcf);
|
ngx_http_geoip_conf_t *gcf);
|
||||||
@ -291,7 +291,8 @@ ngx_http_geoip_org_variable(ngx_http_request_t *r,
|
|||||||
ngx_http_geoip_variable_handler_pt handler =
|
ngx_http_geoip_variable_handler_pt handler =
|
||||||
(ngx_http_geoip_variable_handler_pt) data;
|
(ngx_http_geoip_variable_handler_pt) data;
|
||||||
|
|
||||||
const char *val;
|
size_t len;
|
||||||
|
char *val;
|
||||||
ngx_http_geoip_conf_t *gcf;
|
ngx_http_geoip_conf_t *gcf;
|
||||||
|
|
||||||
gcf = ngx_http_get_module_main_conf(r, ngx_http_geoip_module);
|
gcf = ngx_http_get_module_main_conf(r, ngx_http_geoip_module);
|
||||||
@ -306,11 +307,21 @@ ngx_http_geoip_org_variable(ngx_http_request_t *r,
|
|||||||
goto not_found;
|
goto not_found;
|
||||||
}
|
}
|
||||||
|
|
||||||
v->len = ngx_strlen(val);
|
len = ngx_strlen(val);
|
||||||
|
v->data = ngx_pnalloc(r->pool, len);
|
||||||
|
if (v->data == NULL) {
|
||||||
|
ngx_free(val);
|
||||||
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
ngx_memcpy(v->data, val, len);
|
||||||
|
|
||||||
|
v->len = len;
|
||||||
v->valid = 1;
|
v->valid = 1;
|
||||||
v->no_cacheable = 0;
|
v->no_cacheable = 0;
|
||||||
v->not_found = 0;
|
v->not_found = 0;
|
||||||
v->data = (u_char *) val;
|
|
||||||
|
ngx_free(val);
|
||||||
|
|
||||||
return NGX_OK;
|
return NGX_OK;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user