]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: pattern: new sflag PAT_SF_REGFREE indicates regex_free() is needed
authorWilly Tarreau <w@1wt.eu>
Mon, 2 Nov 2020 18:16:23 +0000 (19:16 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 5 Nov 2020 18:27:08 +0000 (19:27 +0100)
Currently we have no way to know how to delete/prune a pattern in a
generic way. A pattern doesn't contain its own type so we don't know
what function to call. Tree nodes are roughly OK but not lists where
regex are possible. Let's add one new bit for sflags at index time to
indicate that regex_free() will be needed upon deletion. It's not used
for now.

include/haproxy/pattern-t.h
src/pattern.c

index aa77c9aa778f27f704dc5f8edff34086afeed823..b5b4d0bebf3ee65d1e58e84234f37f82583a8f1d 100644 (file)
@@ -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 */
index e4a1e2785b5bdc49e60450a688b45d1e44ba64ad..5c83a5ca9c47fd02aab5c921f81a5976083aa027 100644 (file)
@@ -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);