diff options
author | Igor Sysoev <igor@sysoev.ru> | 2008-12-11 17:32:52 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2008-12-11 17:32:52 +0000 |
commit | 3dde93ba6c1e9be80e43ac497601f65e515357e3 (patch) | |
tree | 6700fa43fffdd251f5d99112baf24d9e8daffa2d /src | |
parent | ac662fbe1be7a9bdcc2a727126df19471663ff72 (diff) | |
download | nginx-3dde93ba6c1e9be80e43ac497601f65e515357e3.tar.gz nginx-3dde93ba6c1e9be80e43ac497601f65e515357e3.zip |
fix segfault if no named location are defined, but are used
Diffstat (limited to 'src')
-rw-r--r-- | src/http/ngx_http_core_module.c | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c index cabb1a172..8c5e90873 100644 --- a/src/http/ngx_http_core_module.c +++ b/src/http/ngx_http_core_module.c @@ -2017,33 +2017,37 @@ ngx_http_named_location(ngx_http_request_t *r, ngx_str_t *name) cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); - for (clcfp = cscf->named_locations; *clcfp; clcfp++) { + if (cscf->named_locations) { - ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, - "test location: \"%V\"", &(*clcfp)->name); + for (clcfp = cscf->named_locations; *clcfp; clcfp++) { - if (name->len != (*clcfp)->name.len - || ngx_strncmp(name->data, (*clcfp)->name.data, name->len) != 0) - { - continue; - } + ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + "test location: \"%V\"", &(*clcfp)->name); - ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, - "using location: %V \"%V?%V\"", name, &r->uri, &r->args); + if (name->len != (*clcfp)->name.len + || ngx_strncmp(name->data, (*clcfp)->name.data, name->len) != 0) + { + continue; + } - r->internal = 1; - r->content_handler = NULL; - r->loc_conf = (*clcfp)->loc_conf; + ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + "using location: %V \"%V?%V\"", + name, &r->uri, &r->args); - ngx_http_update_location_config(r); + r->internal = 1; + r->content_handler = NULL; + r->loc_conf = (*clcfp)->loc_conf; - cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module); + ngx_http_update_location_config(r); - r->phase_handler = cmcf->phase_engine.location_rewrite_index; + cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module); - ngx_http_core_run_phases(r); + r->phase_handler = cmcf->phase_engine.location_rewrite_index; - return NGX_DONE; + ngx_http_core_run_phases(r); + + return NGX_DONE; + } } ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |