summaryrefslogtreecommitdiff
path: root/src/backend/utils
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2012-07-15 13:28:20 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2012-07-15 13:28:20 -0400
commitf81d50dc87ae73f2817c67b205fdcf8d266ca3fb (patch)
treecfa4236829519869ddf6fc0c8916f6a355ec19e0 /src/backend/utils
parent2f9907cb83a12ac432fb81c87cfa735e1229a5bb (diff)
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.
Diffstat (limited to 'src/backend/utils')
-rw-r--r--src/backend/utils/adt/regexp.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/backend/utils/adt/regexp.c b/src/backend/utils/adt/regexp.c
index 405ca6c8e63..84c9d4fee7b 100644
--- a/src/backend/utils/adt/regexp.c
+++ b/src/backend/utils/adt/regexp.c
@@ -182,9 +182,8 @@ RE_compile_and_cache(text *text_re, int cflags)
if (regcomp_result != REG_OKAY)
{
- /* re didn't compile */
+ /* re didn't compile (no need for pg_regfree, if so) */
pg_regerror(regcomp_result, &re_temp.cre_re, errMsg, sizeof(errMsg));
- /* XXX should we pg_regfree here? */
ereport(ERROR,
(errcode(ERRCODE_INVALID_REGULAR_EXPRESSION),
errmsg("invalid regular expression: %s", errMsg)));