aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2021-02-23 13:55:11 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2021-02-23 13:55:34 -0500
commit3db05e76f92846d4b54d7de251b0875cf1e23aa4 (patch)
treea0dc4a46b5582bce6a4f54627d1c85eb4d51b33d
parentd9d076222f5b94a85e0e318339cfc44b8f26022d (diff)
downloadpostgresql-3db05e76f92846d4b54d7de251b0875cf1e23aa4.tar.gz
postgresql-3db05e76f92846d4b54d7de251b0875cf1e23aa4.zip
Suppress compiler warning in new regex match-all detection code.
gcc 10 is smart enough to notice that control could reach this "hasmatch[depth]" assignment with depth < 0, but not smart enough to know that that would require a badly broken NFA graph. Change the assert() to a plain runtime test to shut it up. Per report from Andres Freund. Discussion: https://postgr.es/m/20210223173437.b3ywijygsy6q42gq@alap3.anarazel.de
-rw-r--r--src/backend/regex/regc_nfa.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/backend/regex/regc_nfa.c b/src/backend/regex/regc_nfa.c
index 1a6c9ce1838..69929eddfcc 100644
--- a/src/backend/regex/regc_nfa.c
+++ b/src/backend/regex/regc_nfa.c
@@ -3082,8 +3082,13 @@ checkmatchall_recurse(struct nfa *nfa, struct state *s,
{
/* We found an all-RAINBOW path to the post state */
result = true;
+ /* ... which should not be adjacent to the pre state */
+ if (depth < 0)
+ {
+ NERR(REG_ASSERT);
+ return false;
+ }
/* Record potential match lengths */
- assert(depth >= 0);
hasmatch[depth] = true;
if (foundloop)
{