forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitafcc877
committed
Fix ancient bug in parsing of BRE-mode regular expressions.
brenext(), when parsing a '*' quantifier, forgot to return any "value"for the token; per the equivalent case in next(), it should returnvalue 1 to indicate that greedy rather than non-greedy behavior iswanted. The result is that the compiled regexp could behave like 'x*?'rather than the intended 'x*', if we were unlucky enough to havea zero in v->nextvalue at this point. That seems to happen with somereliability if we have '.*' at the beginning of a BRE-mode regexp,although that depends on the initial contents of a stack-allocatedstruct, so it's not guaranteed to fail.Found by Alexander Lakhin using valgrind testing. This bug seemsto be aboriginal in Spencer's code, so back-patch all the way.Discussion:https://postgr.es/m/16814-6c5e3edd2bdf0d50@postgresql.org1 parent15b824d commitafcc877
File tree
3 files changed
+11
-1
lines changed- src
- backend/regex
- test/modules/test_regex
- expected
- sql
3 files changed
+11
-1
lines changedLines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
994 | 994 |
| |
995 | 995 |
| |
996 | 996 |
| |
997 |
| - | |
| 997 | + | |
998 | 998 |
| |
999 | 999 |
| |
1000 | 1000 |
| |
|
Lines changed: 8 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
614 | 614 |
| |
615 | 615 |
| |
616 | 616 |
| |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
617 | 625 |
| |
618 | 626 |
| |
619 | 627 |
| |
|
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
214 | 214 |
| |
215 | 215 |
| |
216 | 216 |
| |
| 217 | + | |
| 218 | + | |
217 | 219 |
| |
218 | 220 |
| |
219 | 221 |
| |
|
0 commit comments
Comments
(0)