comparison src/http/modules/ngx_http_geoip_module.c @ 516:7efcdb937752 NGINX_0_8_10

nginx 0.8.10 *) Bugfix: memory leaks if GeoIP City database was used. *) Bugfix: in copying temporary files to permanent storage area; the bug had appeared in 0.8.9.
author Igor Sysoev <http://sysoev.ru>
date Mon, 24 Aug 2009 00:00:00 +0400
parents 4b0d7f0bf22b
children 2da4537168f8
comparison
equal deleted inserted replaced
515:607556aed0a1 516:7efcdb937752
179 ngx_http_geoip_city_variable(ngx_http_request_t *r, 179 ngx_http_geoip_city_variable(ngx_http_request_t *r,
180 ngx_http_variable_value_t *v, uintptr_t data) 180 ngx_http_variable_value_t *v, uintptr_t data)
181 { 181 {
182 u_long addr; 182 u_long addr;
183 char *val; 183 char *val;
184 size_t len;
184 GeoIPRecord *gr; 185 GeoIPRecord *gr;
185 struct sockaddr_in *sin; 186 struct sockaddr_in *sin;
186 ngx_http_geoip_conf_t *gcf; 187 ngx_http_geoip_conf_t *gcf;
187 188
188 gcf = ngx_http_get_module_main_conf(r, ngx_http_geoip_module); 189 gcf = ngx_http_get_module_main_conf(r, ngx_http_geoip_module);
205 } 206 }
206 207
207 val = *(char **) ((char *) gr + data); 208 val = *(char **) ((char *) gr + data);
208 209
209 if (val == NULL) { 210 if (val == NULL) {
210 goto not_found; 211 goto no_value;
211 } 212 }
212 213
213 v->len = ngx_strlen(val); 214 len = ngx_strlen(val);
215 v->data = ngx_pnalloc(r->pool, len);
216
217 if (v->data == NULL) {
218 GeoIPRecord_delete(gr);
219 return NGX_ERROR;
220 }
221
222 ngx_memcpy(v->data, val, len);
223
224 v->len = len;
214 v->valid = 1; 225 v->valid = 1;
215 v->no_cacheable = 0; 226 v->no_cacheable = 0;
216 v->not_found = 0; 227 v->not_found = 0;
217 v->data = (u_char *) val; 228
218 229 GeoIPRecord_delete(gr);
219 return NGX_OK; 230
231 return NGX_OK;
232
233 no_value:
234
235 GeoIPRecord_delete(gr);
220 236
221 not_found: 237 not_found:
222 238
223 v->not_found = 1; 239 v->not_found = 1;
224 240