diff options
author | Maxim Dounin <mdounin@mdounin.ru> | 2012-04-23 10:40:01 +0000 |
---|---|---|
committer | Maxim Dounin <mdounin@mdounin.ru> | 2012-04-23 10:40:01 +0000 |
commit | c7bb162ffe3a3e2838c70916aa781084c00e8489 (patch) | |
tree | e323681b1516dae7ac7f462ad448b0cbe355c7c0 /src/http/modules/ngx_http_proxy_module.c | |
parent | 8b89c882cef2c846789a22f65233c60030bf3491 (diff) | |
download | nginx-c7bb162ffe3a3e2838c70916aa781084c00e8489.tar.gz nginx-c7bb162ffe3a3e2838c70916aa781084c00e8489.zip |
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.
Diffstat (limited to 'src/http/modules/ngx_http_proxy_module.c')
-rw-r--r-- | src/http/modules/ngx_http_proxy_module.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/http/modules/ngx_http_proxy_module.c b/src/http/modules/ngx_http_proxy_module.c index d8bcad01a..387f77f9b 100644 --- a/src/http/modules/ngx_http_proxy_module.c +++ b/src/http/modules/ngx_http_proxy_module.c @@ -1497,6 +1497,10 @@ ngx_http_proxy_input_filter_init(void *data) 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 @@ ngx_http_proxy_parse_chunked(ngx_http_request_t *r, ngx_buf_t *buf) } 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 @@ ngx_http_proxy_chunked_filter(ngx_event_pipe_t *p, ngx_buf_t *buf) 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_non_buffered_chunked_filter(void *data, ssize_t bytes) 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; |