]> git.kaiwu.me - nginx.git/commitdiff
Sub filter: restored ngx_http_set_ctx() at the proper place.
authorSergey Kandaurov <pluknet@nginx.com>
Tue, 18 Apr 2017 16:55:23 +0000 (19:55 +0300)
committerSergey Kandaurov <pluknet@nginx.com>
Tue, 18 Apr 2017 16:55:23 +0000 (19:55 +0300)
Previously, ngx_http_sub_header_filter() could fail with a partially
initialized context, later accessed in ngx_http_sub_body_filter()
if called from the perl content handler.

The issue had appeared in 2c045e5b8291 (1.9.4).

A better fix would be to handle ngx_http_send_header() errors in
the perl module, though this doesn't seem to be easy enough.

src/http/modules/ngx_http_sub_filter_module.c

index de58c6f13438b6ea584d54d6ef44f6d8aab3bfaa..6d3de59b09a14e8e0a50dbd32be69af80e31b114 100644 (file)
@@ -248,8 +248,6 @@ ngx_http_sub_header_filter(ngx_http_request_t *r)
                                  ctx->matches->nelts);
     }
 
-    ngx_http_set_ctx(r, ctx, ngx_http_sub_filter_module);
-
     ctx->saved.data = ngx_pnalloc(r->pool, ctx->tables->max_match_len - 1);
     if (ctx->saved.data == NULL) {
         return NGX_ERROR;
@@ -260,6 +258,8 @@ ngx_http_sub_header_filter(ngx_http_request_t *r)
         return NGX_ERROR;
     }
 
+    ngx_http_set_ctx(r, ctx, ngx_http_sub_filter_module);
+
     ctx->offset = ctx->tables->min_match_len - 1;
     ctx->last_out = &ctx->out;