Skip to content

Commit 3db05e7

Browse files
committed
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
1 parent d9d0762 commit 3db05e7

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/backend/regex/regc_nfa.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3082,8 +3082,13 @@ checkmatchall_recurse(struct nfa *nfa, struct state *s,
30823082
{
30833083
/* We found an all-RAINBOW path to the post state */
30843084
result = true;
3085+
/* ... which should not be adjacent to the pre state */
3086+
if (depth < 0)
3087+
{
3088+
NERR(REG_ASSERT);
3089+
return false;
3090+
}
30853091
/* Record potential match lengths */
3086-
assert(depth >= 0);
30873092
hasmatch[depth] = true;
30883093
if (foundloop)
30893094
{

0 commit comments

Comments
 (0)