forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitadb6dbc
committed
Fix recently-exposed portability issue in regex optimization.
fixempties() counts the number of in-arcs in the regex NFA and thenallocates an array of that many arc pointers. If the NFA contains noarcs, this amounts to malloc(0) for which some platforms return NULL.The code mistakenly treats that as indicating out-of-memory. Thus,we can get a bogus "out of memory" failure for some unsatisfiableregexes.This happens only in v15 and earlier, sincebea3d7e switched tousing palloc() rather than bare malloc(). And at least of theplatforms in the buildfarm, only AIX seems to return NULL. So theimpact is pretty narrow. But I don't especially want to ship codethat is failing its own regression tests, so let's fix this forthis week's releases.A quick code survey says that there is only the one place insrc/backend/regex/ that is at risk of doing malloc(0), so we'll justband-aid that place. A more future-proof fix could be to install amalloc() wrapper similar to pg_malloc(). But this code seems unlikelyto change much more in the affected branches, so that's probablyoverkill.The only known test case for this involves a complemented characterclass in a bracket expression, for example [^\s\S], and we didn'tsupport that in v13. So it may be that the problem is unreachablein v13. But I'm not 100% sure of that, so patch v13 too.Discussion:https://postgr.es/m/661fd81b-f069-8f30-1a41-e195c57449b4@gmail.com1 parentf4a0b18 commitadb6dbc
1 file changed
+4
-1
lines changedLines changed: 4 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1994 | 1994 |
| |
1995 | 1995 |
| |
1996 | 1996 |
| |
| 1997 | + | |
| 1998 | + | |
| 1999 | + | |
1997 | 2000 |
| |
1998 | 2001 |
| |
1999 |
| - | |
| 2002 | + | |
2000 | 2003 |
| |
2001 | 2004 |
| |
2002 | 2005 |
| |
|
0 commit comments
Comments
(0)