diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2021-02-21 20:29:11 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2021-02-21 20:29:11 -0500 |
commit | 190c79884aae540c92f017701726ed69265e2dab (patch) | |
tree | 668bca5d783745382052ecba7efd0003731e9025 /src/backend/regex/regexec.c | |
parent | 6ee479abfc27a18c37fe77140d16d3ac31f4ac31 (diff) | |
download | postgresql-190c79884aae540c92f017701726ed69265e2dab.tar.gz postgresql-190c79884aae540c92f017701726ed69265e2dab.zip |
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.
Diffstat (limited to 'src/backend/regex/regexec.c')
-rw-r--r-- | src/backend/regex/regexec.c | 6 |
1 files changed, 3 insertions, 3 deletions
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]; |