From: Tom Lane Date: Sat, 22 Sep 2007 04:37:53 +0000 (+0000) Subject: Doh --- what's really happening on buildfarm member grebe is that its X-Git-Url: http://waps.l3s.uni-hannover.de/gitweb/?a=commitdiff_plain;h=c7abe0a00b81a828d084932e85398bc630b6cc46;p=users%2Fbernd%2Fpostgres.git Doh --- what's really happening on buildfarm member grebe is that its malloc returns NULL for malloc(0). Defend against that case. --- diff --git a/src/backend/utils/adt/regexp.c b/src/backend/utils/adt/regexp.c index eb0cbe7643..f9263063c7 100644 --- a/src/backend/utils/adt/regexp.c +++ b/src/backend/utils/adt/regexp.c @@ -195,10 +195,12 @@ RE_compile_and_cache(text *text_re, int cflags) } /* - * use malloc/free for the cre_pat field because the storage has to - * persist across transactions + * We use malloc/free for the cre_pat field because the storage has to + * persist across transactions, and because we want to get control back + * on out-of-memory. The Max() is because some malloc implementations + * return NULL for malloc(0). */ - re_temp.cre_pat = malloc(text_re_len); + re_temp.cre_pat = malloc(Max(text_re_len, 1)); if (re_temp.cre_pat == NULL) { pg_regfree(&re_temp.cre_re);