# HG changeset patch # User Sergey Kandaurov # Date 1492534523 -10800 # Node ID 201038680680b05ac435191ab2b8ceb5d6785ccf # Parent 3518287d995ed86c71f8ce7ae75650621fad0f17 Sub filter: restored ngx_http_set_ctx() at the proper place. 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. diff -r 3518287d995e -r 201038680680 src/http/modules/ngx_http_sub_filter_module.c --- a/src/http/modules/ngx_http_sub_filter_module.c Tue Apr 18 16:08:46 2017 +0300 +++ b/src/http/modules/ngx_http_sub_filter_module.c Tue Apr 18 19:55:23 2017 +0300 @@ -248,8 +248,6 @@ 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 @@ 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;