diff options
author | Maxim Dounin <mdounin@mdounin.ru> | 2012-08-16 10:58:18 +0000 |
---|---|---|
committer | Maxim Dounin <mdounin@mdounin.ru> | 2012-08-16 10:58:18 +0000 |
commit | 3587e2be23064ebec26c95ea26ff5080ee79a7ae (patch) | |
tree | 9f153c7c3586fb31ce31c3e215751cc28078bffe /src | |
parent | 9aac01a76edeccd7760e99de23eac7e447cf4fde (diff) | |
download | nginx-3587e2be23064ebec26c95ea26ff5080ee79a7ae.tar.gz nginx-3587e2be23064ebec26c95ea26ff5080ee79a7ae.zip |
Map: fixed optimization of variables as values.
Previous code incorrectly used ctx->var_values as an array of pointers to
ngx_http_variable_value_t, but the array contains structures, not pointers.
Additionally, ctx->var_values inspection failed to properly set var on
match.
Diffstat (limited to 'src')
-rw-r--r-- | src/http/modules/ngx_http_map_module.c | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/src/http/modules/ngx_http_map_module.c b/src/http/modules/ngx_http_map_module.c index e8a4ab4cc..54f9ec445 100644 --- a/src/http/modules/ngx_http_map_module.c +++ b/src/http/modules/ngx_http_map_module.c @@ -416,11 +416,12 @@ ngx_http_map(ngx_conf_t *cf, ngx_command_t *dummy, void *conf) for (i = 0; i < ctx->var_values.nelts; i++) { if (index == (ngx_int_t) var[i].data) { + var = &var[i]; goto found; } } - var = ngx_palloc(ctx->keys.pool, sizeof(ngx_http_variable_value_t)); + var = ngx_array_push(&ctx->var_values); if (var == NULL) { return NGX_CONF_ERROR; } @@ -431,13 +432,6 @@ ngx_http_map(ngx_conf_t *cf, ngx_command_t *dummy, void *conf) var->len = 0; var->data = (u_char *) index; - vp = ngx_array_push(&ctx->var_values); - if (vp == NULL) { - return NGX_CONF_ERROR; - } - - *vp = var; - goto found; } |