Mercurial > hg > nginx
comparison src/http/modules/ngx_http_sub_filter_module.c @ 6984:201038680680
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.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 18 Apr 2017 19:55:23 +0300 |
parents | f18c285c2e59 |
children |
comparison
equal
deleted
inserted
replaced
6983:3518287d995e | 6984:201038680680 |
---|---|
246 | 246 |
247 ngx_http_sub_init_tables(ctx->tables, ctx->matches->elts, | 247 ngx_http_sub_init_tables(ctx->tables, ctx->matches->elts, |
248 ctx->matches->nelts); | 248 ctx->matches->nelts); |
249 } | 249 } |
250 | 250 |
251 ngx_http_set_ctx(r, ctx, ngx_http_sub_filter_module); | |
252 | |
253 ctx->saved.data = ngx_pnalloc(r->pool, ctx->tables->max_match_len - 1); | 251 ctx->saved.data = ngx_pnalloc(r->pool, ctx->tables->max_match_len - 1); |
254 if (ctx->saved.data == NULL) { | 252 if (ctx->saved.data == NULL) { |
255 return NGX_ERROR; | 253 return NGX_ERROR; |
256 } | 254 } |
257 | 255 |
258 ctx->looked.data = ngx_pnalloc(r->pool, ctx->tables->max_match_len - 1); | 256 ctx->looked.data = ngx_pnalloc(r->pool, ctx->tables->max_match_len - 1); |
259 if (ctx->looked.data == NULL) { | 257 if (ctx->looked.data == NULL) { |
260 return NGX_ERROR; | 258 return NGX_ERROR; |
261 } | 259 } |
260 | |
261 ngx_http_set_ctx(r, ctx, ngx_http_sub_filter_module); | |
262 | 262 |
263 ctx->offset = ctx->tables->min_match_len - 1; | 263 ctx->offset = ctx->tables->min_match_len - 1; |
264 ctx->last_out = &ctx->out; | 264 ctx->last_out = &ctx->out; |
265 | 265 |
266 r->filter_need_in_memory = 1; | 266 r->filter_need_in_memory = 1; |