From 190c79884aae540c92f017701726ed69265e2dab Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sun, 21 Feb 2021 20:29:11 -0500 Subject: Simplify memory management for regex DFAs a little. Coverity complained that functions in regexec.c might leak DFA storage. It's wrong, but this logic is confusing enough that it's not so surprising Coverity couldn't make sense of it. Rewrite in hopes of making it more legible to humans as well as machines. --- src/backend/regex/regexec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/backend/regex/regexec.c') diff --git a/src/backend/regex/regexec.c b/src/backend/regex/regexec.c index 2a1ef0176a5..cf959899489 100644 --- a/src/backend/regex/regexec.c +++ b/src/backend/regex/regexec.c @@ -77,8 +77,8 @@ struct dfa chr *lastpost; /* location of last cache-flushed success */ chr *lastnopr; /* location of last cache-flushed NOPROGRESS */ struct sset *search; /* replacement-search-pointer memory */ - int cptsmalloced; /* were the areas individually malloced? */ - char *mallocarea; /* self, or master malloced area, or NULL */ + bool ismalloced; /* should this struct dfa be freed? */ + bool arraysmalloced; /* should its subsidiary arrays be freed? */ }; #define WORK 1 /* number of work bitvectors needed */ @@ -88,7 +88,7 @@ struct dfa #define FEWCOLORS 15 struct smalldfa { - struct dfa dfa; + struct dfa dfa; /* must be first */ struct sset ssets[FEWSTATES * 2]; unsigned statesarea[FEWSTATES * 2 + WORK]; struct sset *outsarea[FEWSTATES * 2 * FEWCOLORS]; -- cgit v1.2.3