]> granicus.if.org Git - postgresql/commit
Fix two low-probability memory leaks in regular expression parsing.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 18 Jul 2014 17:00:27 +0000 (13:00 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 18 Jul 2014 17:00:48 +0000 (13:00 -0400)
commita223b9e361bae993a3e7d845a30b46fe2c5feca5
tree79b6fa84aaccdacc4e4cdec30094a6bda134e6b1
parentb42f09fc80ce0848233753bbf38643b88e208786
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.
src/backend/regex/regcomp.c