pgsql: Fix two low-probability memory leaks in regular expression parsi

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix two low-probability memory leaks in regular expression parsi
Date: 2014-07-18 17:01:35
Message-ID: E1X8BXL-00007J-ME@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix two low-probability memory leaks in regular expression parsing.

If pg_regcomp failed after having invoked markst/cleanst, it would leak any
"struct subre" nodes it had created. (We've already detected all regex
syntax errors at that point, so the only likely causes of later failure
would be query cancel or out-of-memory.) To fix, make sure freesrnode
knows the difference between the pre-cleanst and post-cleanst cleanup
procedures. Add some documentation of this less-than-obvious point.

Also, newlacon did the wrong thing with an out-of-memory failure from
realloc(), so that the previously allocated array would be leaked.

Both of these are pretty low-probability scenarios, but a bug is a bug,
so patch all the way back.

Per bug #10976 from Arthur O'Dwyer.

Branch
------
REL8_4_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/e0a233744744d060fb07e25405bcc7dbba9c807f

Modified Files
--------------
src/backend/regex/regcomp.c | 31 ++++++++++++++++++++++++-------
1 file changed, 24 insertions(+), 7 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Noah Misch 2014-07-18 20:16:16 pgsql: Limit pg_upgrade authentication advice to always-secure techniqu
Previous Message Magnus Hagander 2014-07-17 11:20:09 pgsql: Revert broken change to pgevent.c