Klaus Demo nginx / 0b23391
Merge of r4648, r4649, r4650: memory leak with $geoip_org. Patch by Denis F. Latypoff (slightly modified). Maxim Dounin 9 years ago
1 changed file(s) with 15 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
2727 } ngx_http_geoip_var_t;
2828
2929
30 typedef const char *(*ngx_http_geoip_variable_handler_pt)(GeoIP *, u_long addr);
30 typedef char *(*ngx_http_geoip_variable_handler_pt)(GeoIP *, u_long addr);
3131
3232 static u_long ngx_http_geoip_addr(ngx_http_request_t *r,
3333 ngx_http_geoip_conf_t *gcf);
290290 ngx_http_geoip_variable_handler_pt handler =
291291 (ngx_http_geoip_variable_handler_pt) data;
292292
293 const char *val;
293 size_t len;
294 char *val;
294295 ngx_http_geoip_conf_t *gcf;
295296
296297 gcf = ngx_http_get_module_main_conf(r, ngx_http_geoip_module);
305306 goto not_found;
306307 }
307308
308 v->len = ngx_strlen(val);
309 len = ngx_strlen(val);
310 v->data = ngx_pnalloc(r->pool, len);
311 if (v->data == NULL) {
312 ngx_free(val);
313 return NGX_ERROR;
314 }
315
316 ngx_memcpy(v->data, val, len);
317
318 v->len = len;
309319 v->valid = 1;
310320 v->no_cacheable = 0;
311321 v->not_found = 0;
312 v->data = (u_char *) val;
322
323 ngx_free(val);
313324
314325 return NGX_OK;
315326