Skip to content

Commit

Permalink
Geo: fixed access to already freed memory.
Browse files Browse the repository at this point in the history
Previously, in "ranges" mode when all added ranges were deleted,
the ctx.high.low[i] was left pointing to a temporary array.
  • Loading branch information
VBart committed Aug 18, 2016
1 parent 50ba1a2 commit 535550b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/http/modules/ngx_http_geo_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,12 @@ ngx_http_geo_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
for (i = 0; i < 0x10000; i++) {
a = (ngx_array_t *) ctx.high.low[i];

if (a == NULL || a->nelts == 0) {
if (a == NULL) {
continue;
}

if (a->nelts == 0) {
ctx.high.low[i] = NULL;
continue;
}

Expand Down
7 changes: 6 additions & 1 deletion src/stream/ngx_stream_geo_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,12 @@ ngx_stream_geo_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
for (i = 0; i < 0x10000; i++) {
a = (ngx_array_t *) ctx.high.low[i];

if (a == NULL || a->nelts == 0) {
if (a == NULL) {
continue;
}

if (a->nelts == 0) {
ctx.high.low[i] = NULL;
continue;
}

Expand Down

0 comments on commit 535550b

Please sign in to comment.