Mercurial > hg > nginx
comparison src/http/modules/ngx_http_geoip_module.c @ 4647:a321eadcb16c
Fixed memory leak if $geoip_org variable was used.
Patch by Denis F. Latypoff (slightly modified).
author | Ruslan Ermilov <ru@nginx.com> |
---|---|
date | Mon, 28 May 2012 13:17:48 +0000 |
parents | 3152e4c371d7 |
children | 70296867c740 |
comparison
equal
deleted
inserted
replaced
4646:959371df1806 | 4647:a321eadcb16c |
---|---|
289 ngx_http_variable_value_t *v, uintptr_t data) | 289 ngx_http_variable_value_t *v, uintptr_t data) |
290 { | 290 { |
291 ngx_http_geoip_variable_handler_pt handler = | 291 ngx_http_geoip_variable_handler_pt handler = |
292 (ngx_http_geoip_variable_handler_pt) data; | 292 (ngx_http_geoip_variable_handler_pt) data; |
293 | 293 |
294 size_t len; | |
294 const char *val; | 295 const char *val; |
295 ngx_http_geoip_conf_t *gcf; | 296 ngx_http_geoip_conf_t *gcf; |
296 | 297 |
297 gcf = ngx_http_get_module_main_conf(r, ngx_http_geoip_module); | 298 gcf = ngx_http_get_module_main_conf(r, ngx_http_geoip_module); |
298 | 299 |
304 | 305 |
305 if (val == NULL) { | 306 if (val == NULL) { |
306 goto not_found; | 307 goto not_found; |
307 } | 308 } |
308 | 309 |
309 v->len = ngx_strlen(val); | 310 len = ngx_strlen(val); |
311 v->data = ngx_pnalloc(r->pool, len); | |
312 if (v->data == NULL) { | |
313 ngx_free(val); | |
314 return NGX_ERROR; | |
315 } | |
316 | |
317 ngx_memcpy(v->data, val, len); | |
318 | |
319 v->len = len; | |
310 v->valid = 1; | 320 v->valid = 1; |
311 v->no_cacheable = 0; | 321 v->no_cacheable = 0; |
312 v->not_found = 0; | 322 v->not_found = 0; |
313 v->data = (u_char *) val; | 323 |
324 ngx_free(val); | |
314 | 325 |
315 return NGX_OK; | 326 return NGX_OK; |
316 | 327 |
317 not_found: | 328 not_found: |
318 | 329 |