summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRuslan Ermilov <ru@nginx.com>2012-05-28 13:17:48 +0000
committerRuslan Ermilov <ru@nginx.com>2012-05-28 13:17:48 +0000
commit9fbd0d7c1dec054fd8c8ef104ad26bccde853289 (patch)
tree523976baabb1e2fe652d2ee74e2da4954efba301 /src
parent526fd681b53ad3ed3e912ff98bf012709e2f03b4 (diff)
downloadnginx-9fbd0d7c1dec054fd8c8ef104ad26bccde853289.tar.gz
nginx-9fbd0d7c1dec054fd8c8ef104ad26bccde853289.tar.bz2
Fixed memory leak if $geoip_org variable was used.
Patch by Denis F. Latypoff (slightly modified).
Diffstat (limited to 'src')
-rw-r--r--src/http/modules/ngx_http_geoip_module.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/http/modules/ngx_http_geoip_module.c b/src/http/modules/ngx_http_geoip_module.c
index abc79cdfe..8da18e957 100644
--- a/src/http/modules/ngx_http_geoip_module.c
+++ b/src/http/modules/ngx_http_geoip_module.c
@@ -291,6 +291,7 @@ ngx_http_geoip_org_variable(ngx_http_request_t *r,
ngx_http_geoip_variable_handler_pt handler =
(ngx_http_geoip_variable_handler_pt) data;
+ size_t len;
const char *val;
ngx_http_geoip_conf_t *gcf;
@@ -306,11 +307,21 @@ ngx_http_geoip_org_variable(ngx_http_request_t *r,
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->no_cacheable = 0;
v->not_found = 0;
- v->data = (u_char *) val;
+
+ ngx_free(val);
return NGX_OK;