fix segfault if no named location are defined, but are used
Igor Sysoev
13 years ago
2016 | 2016 | |
2017 | 2017 | cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); |
2018 | 2018 | |
2019 | for (clcfp = cscf->named_locations; *clcfp; clcfp++) { | |
2020 | ||
2021 | ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
2022 | "test location: \"%V\"", &(*clcfp)->name); | |
2023 | ||
2024 | if (name->len != (*clcfp)->name.len | |
2025 | || ngx_strncmp(name->data, (*clcfp)->name.data, name->len) != 0) | |
2026 | { | |
2027 | continue; | |
2028 | } | |
2029 | ||
2030 | ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
2031 | "using location: %V \"%V?%V\"", name, &r->uri, &r->args); | |
2032 | ||
2033 | r->internal = 1; | |
2034 | r->content_handler = NULL; | |
2035 | r->loc_conf = (*clcfp)->loc_conf; | |
2036 | ||
2037 | ngx_http_update_location_config(r); | |
2038 | ||
2039 | cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module); | |
2040 | ||
2041 | r->phase_handler = cmcf->phase_engine.location_rewrite_index; | |
2042 | ||
2043 | ngx_http_core_run_phases(r); | |
2044 | ||
2045 | return NGX_DONE; | |
2019 | if (cscf->named_locations) { | |
2020 | ||
2021 | for (clcfp = cscf->named_locations; *clcfp; clcfp++) { | |
2022 | ||
2023 | ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
2024 | "test location: \"%V\"", &(*clcfp)->name); | |
2025 | ||
2026 | if (name->len != (*clcfp)->name.len | |
2027 | || ngx_strncmp(name->data, (*clcfp)->name.data, name->len) != 0) | |
2028 | { | |
2029 | continue; | |
2030 | } | |
2031 | ||
2032 | ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
2033 | "using location: %V \"%V?%V\"", | |
2034 | name, &r->uri, &r->args); | |
2035 | ||
2036 | r->internal = 1; | |
2037 | r->content_handler = NULL; | |
2038 | r->loc_conf = (*clcfp)->loc_conf; | |
2039 | ||
2040 | ngx_http_update_location_config(r); | |
2041 | ||
2042 | cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module); | |
2043 | ||
2044 | r->phase_handler = cmcf->phase_engine.location_rewrite_index; | |
2045 | ||
2046 | ngx_http_core_run_phases(r); | |
2047 | ||
2048 | return NGX_DONE; | |
2049 | } | |
2046 | 2050 | } |
2047 | 2051 | |
2048 | 2052 | ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |