# HG changeset patch # User Maxim Dounin # Date 1335177601 0 # Node ID 8036fc6af2dfe2babb953e95b66b0c966fb36971 # Parent 084137d883ecf0f85404ff4ef081c95ce6830633 Proxy: added ctx checking to input filters. The proxy module context may be NULL in case of filter finalization (e.g. by image_filter) followed by an internal redirect. This needs some better handling, but for now just check if ctx is still here. diff -r 084137d883ec -r 8036fc6af2df src/http/modules/ngx_http_proxy_module.c --- a/src/http/modules/ngx_http_proxy_module.c Sat Apr 21 19:02:21 2012 +0000 +++ b/src/http/modules/ngx_http_proxy_module.c Mon Apr 23 10:40:01 2012 +0000 @@ -1497,6 +1497,10 @@ u = r->upstream; ctx = ngx_http_get_module_ctx(r, ngx_http_proxy_module); + if (ctx == NULL) { + return NGX_ERROR; + } + ngx_log_debug4(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "http proxy filter init s:%d h:%d c:%d l:%O", u->headers_in.status_n, ctx->head, u->headers_in.chunked, @@ -1636,6 +1640,11 @@ } state; ctx = ngx_http_get_module_ctx(r, ngx_http_proxy_module); + + if (ctx == NULL) { + return NGX_ERROR; + } + state = ctx->state; if (state == sw_chunk_data && ctx->size == 0) { @@ -1883,6 +1892,10 @@ r = p->input_ctx; ctx = ngx_http_get_module_ctx(r, ngx_http_proxy_module); + if (ctx == NULL) { + return NGX_ERROR; + } + b = NULL; prev = &buf->shadow; @@ -2064,6 +2077,11 @@ ngx_http_proxy_ctx_t *ctx; ctx = ngx_http_get_module_ctx(r, ngx_http_proxy_module); + + if (ctx == NULL) { + return NGX_ERROR; + } + u = r->upstream; buf = &u->buffer;