Commit b05e49ce by Geoff Simmons

Copy the match subject into workspace if it's not already in workspace,

so that backref/namedref are guaranteed to return strings in workspace.
parent f1bb0147
......@@ -557,18 +557,32 @@ match(VRT_CTX, pcre2_code *code, VCL_STRING subject, VCL_INT len,
uint32_t options, pcre2_match_data *mdata, pcre2_match_context *mctx,
const char * restrict const context, const char * restrict const caller)
{
PCRE2_SPTR safe_subject;
int ret;
uintptr_t snap;
char *msg;
if (subject == NULL)
subject = "";
if (len == 0)
len = PCRE2_ZERO_TERMINATED;
if (subject == NULL) {
safe_subject = (PCRE2_SPTR)"";
len = 0;
}
else if (len == 0)
len = strlen(subject);
if (subject != NULL) {
if (WS_Inside(ctx->ws, subject, subject + len))
safe_subject = (PCRE2_SPTR)subject;
else if ((safe_subject = WS_Copy(ctx->ws,
(const void *) subject, len))
== NULL) {
VERRNOMEM(ctx, "in %s%s: copying subject to workspace",
context, caller);
return 0;
}
}
/* XXX param for start_offset */
ret = pcre2_match(code, (PCRE2_SPTR)subject, (PCRE2_SIZE)len, 0,
options, mdata, mctx);
ret = pcre2_match(code, safe_subject, (PCRE2_SIZE)len, 0, options,
mdata, mctx);
if (ret == PCRE2_ERROR_NOMATCH)
return 0;
assert(ret != PCRE2_ERROR_PARTIAL); /* XXX */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment