summaryrefslogtreecommitdiff
path: root/src/configfile-glue.c
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2021-11-22 19:46:05 -0500
committerGlenn Strauss <gstrauss@gluelogic.com>2021-11-22 22:33:05 -0500
commitc378e3ad8ca6a31b0760f127bb31cad25b8b98dd (patch)
tree4050314e24e43ac7a788869bcc625527d221e3b1 /src/configfile-glue.c
parent670b3a395ff6365bc92889d5aafd72e362dc97c2 (diff)
downloadlighttpd-git-c378e3ad8ca6a31b0760f127bb31cad25b8b98dd.tar.gz
[core] allocate pcre output vector on demand
allocate pcre output vector on demand for saved config captures (similar to what is done in lighttpd for pcre2 support)
Diffstat (limited to 'src/configfile-glue.c')
-rw-r--r--src/configfile-glue.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/configfile-glue.c b/src/configfile-glue.c
index 7602e419..e5403626 100644
--- a/src/configfile-glue.c
+++ b/src/configfile-glue.c
@@ -687,16 +687,18 @@ static int config_pcre_match(request_st * const r, const data_config * const dc,
matches, sizeof(matches)/sizeof(*matches));
}
- #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[capture_offset] = r->cond_match_data + capture_offset;
+ if (__builtin_expect( (NULL == cond_match->matches), 0)) {
+ /*(allocate on demand)*/
+ cond_match->matches = malloc(dc->ovec_nelts * sizeof(int *));
+ force_assert(cond_match->matches);
+ }
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,
- cond_match->matches, elementsof(cond_match->matches));
+ cond_match->matches, dc->ovec_nelts);
return cond_match->captures;
#else