Go to file
Tom Lane 6ab39c0274 Fix recently-exposed portability issue in regex optimization.
fixempties() counts the number of in-arcs in the regex NFA and then
allocates an array of that many arc pointers.  If the NFA contains no
arcs, 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 unsatisfiable
regexes.

This happens only in v15 and earlier, since bea3d7e38 switched to
using palloc() rather than bare malloc().  And at least of the
platforms in the buildfarm, only AIX seems to return NULL.  So the
impact is pretty narrow.  But I don't especially want to ship code
that is failing its own regression tests, so let's fix this for
this week's releases.

A quick code survey says that there is only the one place in
src/backend/regex/ that is at risk of doing malloc(0), so we'll just
band-aid that place.  A more future-proof fix could be to install a
malloc() wrapper similar to pg_malloc().  But this code seems unlikely
to change much more in the affected branches, so that's probably
overkill.

The only known test case for this involves a complemented character
class in a bracket expression, for example [^\s\S], and we didn't
support that in v13.  So it may be that the problem is unreachable
in v13.  But I'm not 100% sure of that, so patch v13 too.

Discussion: https://postgr.es/m/661fd81b-f069-8f30-1a41-e195c57449b4@gmail.com
2024-11-17 14:14:06 -05:00
config Log LLVM library version in configure output. 2023-10-22 14:24:04 +13:00
contrib Count contrib/bloom index scans in pgstat view. 2024-11-12 20:57:39 -05:00
doc Release notes for 17.2, 16.6, 15.10, 14.15, 13.18, 12.22. 2024-11-16 17:09:53 -05:00
src Fix recently-exposed portability issue in regex optimization. 2024-11-17 14:14:06 -05:00
.cirrus.star ci: Prepare to make compute resources for CI configurable 2023-08-23 15:15:29 -07:00
.cirrus.tasks.yml ci: Pin MacPorts version to 2.9.3. 2024-07-25 14:49:19 +12:00
.cirrus.yml ci: Make compute resources for CI configurable 2023-08-23 15:15:29 -07:00
.dir-locals.el
.editorconfig
.git-blame-ignore-revs Backpatch addition of .git-blame-ignore-revs 2022-08-05 19:36:24 +02:00
.gitattributes Remove non-existing file from .gitattributes 2024-02-16 11:40:57 +01:00
.gitignore Add portlock directory to .gitignore 2022-11-26 07:47:01 -05:00
aclocal.m4
configure Stamp 15.9. 2024-11-11 17:45:41 -05:00
configure.ac Stamp 15.9. 2024-11-11 17:45:41 -05:00
COPYRIGHT Update copyright for 2024 2024-01-03 20:49:04 -05:00
GNUmakefile.in Remove temporary portlock directory during make [dist]clean. 2022-11-26 10:30:46 -05:00
HISTORY
Makefile Dynamically find correct installation docs in Makefile. 2022-01-19 14:48:25 +01:00
README
README.git

PostgreSQL Database Management System
=====================================

This directory contains the source code distribution of the PostgreSQL
database management system.

PostgreSQL is an advanced object-relational database management system
that supports an extended subset of the SQL standard, including
transactions, foreign keys, subqueries, triggers, user-defined types
and functions.  This distribution also contains C language bindings.

PostgreSQL has many language interfaces, many of which are listed here:

	https://www.postgresql.org/download/

See the file INSTALL for instructions on how to build and install
PostgreSQL.  That file also lists supported operating systems and
hardware platforms and contains information regarding any other
software packages that are required to build or run the PostgreSQL
system.  Copyright and license information can be found in the
file COPYRIGHT.  A comprehensive documentation set is included in this
distribution; it can be read as described in the installation
instructions.

The latest version of this software may be obtained at
https://www.postgresql.org/download/.  For more information look at our
web site located at https://www.postgresql.org/.