diff options
author | Glenn Strauss <gstrauss@gluelogic.com> | 2021-11-22 00:49:48 -0500 |
---|---|---|
committer | Glenn Strauss <gstrauss@gluelogic.com> | 2021-11-22 16:34:17 -0500 |
commit | 670b3a395ff6365bc92889d5aafd72e362dc97c2 (patch) | |
tree | d3248c45c29420f35c068b950fc2e6ef85452647 /src/configfile-glue.c | |
parent | 7512d82ca49f1b579819c2974c61de4e3137c70b (diff) | |
download | lighttpd-git-670b3a395ff6365bc92889d5aafd72e362dc97c2.tar.gz |
[core] allocate one fewer cond_match_t, if needed
allocate one fewer cond_match_t in r->cond_match_data, if any are needed
Diffstat (limited to 'src/configfile-glue.c')
-rw-r--r-- | src/configfile-glue.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/configfile-glue.c b/src/configfile-glue.c index f4fbea41..7602e419 100644 --- a/src/configfile-glue.c +++ b/src/configfile-glue.c @@ -651,8 +651,9 @@ static int config_pcre_match(request_st * const r, const data_config * const dc, return pcre2_match(dc->code, (PCRE2_SPTR)BUF_PTR_LEN(b), 0, 0, dc->match_data, NULL); + const int capture_offset = dc->capture_idx - 1; cond_match_t * const cond_match = - r->cond_match[dc->capture_idx] = r->cond_match_data + dc->capture_idx; + r->cond_match[capture_offset] = r->cond_match_data + capture_offset; pcre2_match_data *match_data = cond_match->match_data; if (__builtin_expect( (NULL == match_data), 0)) { /*(allocate on demand)*/ @@ -689,8 +690,9 @@ static int config_pcre_match(request_st * const r, const data_config * const dc, #ifndef elementsof #define elementsof(x) (sizeof(x) / sizeof(x[0])) #endif + const int capture_offset = dc->capture_idx - 1; cond_match_t * const cond_match = - r->cond_match[dc->capture_idx] = r->cond_match_data + dc->capture_idx; + r->cond_match[capture_offset] = r->cond_match_data + capture_offset; cond_match->comp_value = b; /*holds pointer to b (!) for pattern subst*/ cond_match->captures = pcre_exec(dc->regex, dc->regex_study, BUF_PTR_LEN(b), 0, 0, |