aboutsummaryrefslogtreecommitdiff
path: root/src/http/ngx_http_variables.c
diff options
context:
space:
mode:
authorRoman Arutyunyan <arut@nginx.com>2018-12-11 13:09:00 +0300
committerRoman Arutyunyan <arut@nginx.com>2018-12-11 13:09:00 +0300
commit746fba0d79c6909e9e09b4d1cb9ddbf052ab545e (patch)
tree3d0fb8a6a475c69bab1971030fe52142523f54bb /src/http/ngx_http_variables.c
parent7b7f7c1458a66d2ed53e547a2efa775b04034f89 (diff)
downloadnginx-746fba0d79c6909e9e09b4d1cb9ddbf052ab545e.tar.gz
nginx-746fba0d79c6909e9e09b4d1cb9ddbf052ab545e.zip
Copy regex unnamed captures to cloned subrequests.
Previously, unnamed regex captures matched in the parent request, were not available in a cloned subrequest. Now 3 fields related to unnamed captures are copied to a cloned subrequest: r->ncaptures, r->captures and r->captures_data. Since r->captures cannot be changed by either request after creating a clone, a new flag r->realloc_captures is introduced to force reallocation of r->captures. The issue was reported as a proxy_cache_background_update misbehavior in http://mailman.nginx.org/pipermail/nginx/2018-December/057251.html.
Diffstat (limited to 'src/http/ngx_http_variables.c')
-rw-r--r--src/http/ngx_http_variables.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/http/ngx_http_variables.c b/src/http/ngx_http_variables.c
index 2deb9689e..31321b290 100644
--- a/src/http/ngx_http_variables.c
+++ b/src/http/ngx_http_variables.c
@@ -2504,7 +2504,9 @@ ngx_http_regex_exec(ngx_http_request_t *r, ngx_http_regex_t *re, ngx_str_t *s)
if (re->ncaptures) {
len = cmcf->ncaptures;
- if (r->captures == NULL) {
+ if (r->captures == NULL || r->realloc_captures) {
+ r->realloc_captures = 0;
+
r->captures = ngx_palloc(r->pool, len * sizeof(int));
if (r->captures == NULL) {
return NGX_ERROR;