Fix some possible low-memory failures in regexp compilation.

Tom Lane <tgl@sss.pgh.pa.us>

Commit: c5bfcc18a09b3f56ae0fd434ff6c72bd185949c1
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: 2015-08-12T04:48:28Z
Releases: 9.5.0
Fix some possible low-memory failures in regexp compilation.

newnfa() failed to set the regex error state when malloc() fails.
Several places in regcomp.c failed to check for an error after calling
subre().  Each of these mistakes could lead to null-pointer-dereference
crashes in memory-starved backends.

Report and patch by Andreas Seltenreich.  Back-patch to all branches.

Files

PathChange+/−
src/backend/regex/regc_nfa.c modified +3 −0
src/backend/regex/regcomp.c modified +3 −0