Skip to content

Commit 94470b9

Browse files
committed
Doh --- what's really happening on buildfarm member grebe is that its
malloc returns NULL for malloc(0). Defend against that case.
1 parent e152893 commit 94470b9

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/backend/utils/adt/regexp.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/adt/regexp.c,v 1.74 2007/09/21 22:52:52 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/regexp.c,v 1.75 2007/09/22 04:37:53 tgl Exp $
1212
*
1313
* Alistair Crooks added the code for the regex caching
1414
* agc - cached the regular expressions used - there's a good chance
@@ -195,10 +195,12 @@ RE_compile_and_cache(text *text_re, int cflags)
195195
}
196196

197197
/*
198-
* use malloc/free for the cre_pat field because the storage has to
199-
* persist across transactions
198+
* We use malloc/free for the cre_pat field because the storage has to
199+
* persist across transactions, and because we want to get control back
200+
* on out-of-memory. The Max() is because some malloc implementations
201+
* return NULL for malloc(0).
200202
*/
201-
re_temp.cre_pat = malloc(text_re_len);
203+
re_temp.cre_pat = malloc(Max(text_re_len, 1));
202204
if (re_temp.cre_pat == NULL)
203205
{
204206
pg_regfree(&re_temp.cre_re);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy