Re: BUG #16814: Invalid memory access on regexp_match with .* and BRE
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: exclusion@gmail.com
Cc: pgsql-bugs@lists.postgresql.org
Date: 2021-01-08T17:19:46Z
Lists: pgsql-bugs
PG Bug reporting form <noreply@postgresql.org> writes:
> When executing the following regexp call:
> select regexp_match('abc', '.*', 'b');
> valgrind detects an error:
Hah, nice one. It gives the wrong answer too, at least it does most of
the time for me:
# select regexp_match('abc', '.*', 'b');
regexp_match
--------------
{""}
(1 row)
That's because it's acting like the pattern is '.*?' (prefer shortest
match) rather than '.*'.
This bug is well over the age of consent, btw. Tcl's got it too,
so it surely is aboriginal in Henry Spencer's code.
Thanks for the report!
regards, tom lane
Commits
-
Fix ancient bug in parsing of BRE-mode regular expressions.
- afcc8772edce 14.0 landed
- 8354371d0a53 12.6 landed
- 769908811b8b 11.11 landed
- 49c928c0c067 13.2 landed
- 2d540ac5f1f3 10.16 landed
- 0c23f30fad29 9.5.25 landed
- 085a1cfb3d5f 9.6.21 landed