diff --git a/include/haproxy/pattern-t.h b/include/haproxy/pattern-t.h index aa77c9aa7..b5b4d0beb 100644 --- a/include/haproxy/pattern-t.h +++ b/include/haproxy/pattern-t.h @@ -69,6 +69,7 @@ enum { /* possible flags for patterns storage */ enum { PAT_SF_TREE = 1 << 0, /* some patterns are arranged in a tree */ + PAT_SF_REGFREE = 1 << 1, /* run regex_free() on the pointer */ }; /* ACL match methods */ diff --git a/src/pattern.c b/src/pattern.c index e4a1e2785..5c83a5ca9 100644 --- a/src/pattern.c +++ b/src/pattern.c @@ -1240,6 +1240,7 @@ int pat_idx_list_reg_cap(struct pattern_expr *expr, struct pattern *pat, int cap memcpy(&patl->pat, pat, sizeof(*pat)); /* compile regex */ + patl->pat.sflags |= PAT_SF_REGFREE; if (!(patl->pat.ptr.reg = regex_comp(pat->ptr.str, !(expr->mflags & PAT_MF_IGNORE_CASE), cap, err))) { free(patl);