]> granicus.if.org Git - postgresql/commit
Prevent corner-case core dump in rfree().
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 15 Jul 2012 17:28:20 +0000 (13:28 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 15 Jul 2012 17:28:20 +0000 (13:28 -0400)
commitf81d50dc87ae73f2817c67b205fdcf8d266ca3fb
treecfa4236829519869ddf6fc0c8916f6a355ec19e0
parent2f9907cb83a12ac432fb81c87cfa735e1229a5bb
Prevent corner-case core dump in rfree().

rfree() failed to cope with the case that pg_regcomp() had initialized the
regex_t struct but then failed to allocate any memory for re->re_guts (ie,
the first malloc call in pg_regcomp() failed).  It would try to touch the
guts struct anyway, and thus dump core.  This is a sufficiently narrow
corner case that it's not surprising it's never been seen in the field;
but still a bug is a bug, so patch all active branches.

Noted while investigating whether we need to call pg_regfree after a
failure return from pg_regcomp.  Other than this bug, it turns out we
don't, so adjust comments appropriately.
src/backend/regex/regcomp.c
src/backend/utils/adt/regexp.c