diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2012-12-29 22:56:31 -0800 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2012-12-30 00:13:15 -0800 |
commit | bbf0d723ed2335add96bcc0f842885d8a5d8b6da (patch) | |
tree | 321231ad125a0b3cae1ca1832ab8347db2b3b7e7 /lib/regex_internal.c | |
parent | 585a8dcf51a46cd9965c6881cfff6eddbae06d48 (diff) | |
download | gnulib-bbf0d723ed2335add96bcc0f842885d8a5d8b6da.tar.gz |
regex: port to hosts where malloc (0) == NULL
Reported by Aharon Robbins in
<http://sourceware.org/ml/libc-alpha/2012-12/msg00456.html>.
* lib/regex_internal.c (re_node_set_alloc):
Don't assume that malloc (0) yields nonnull.
* lib/regex_internal.h (MALLOC_0_IS_NONNULL): New macro.
* m4/regex.m4 (gl_PREREQ_REGEX): Require gl_EEMALLOC.
* modules/regex (Files): Add m4/eealloc.m4.
Diffstat (limited to 'lib/regex_internal.c')
-rw-r--r-- | lib/regex_internal.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/regex_internal.c b/lib/regex_internal.c index 62b029dbfa..cac0190994 100644 --- a/lib/regex_internal.c +++ b/lib/regex_internal.c @@ -974,7 +974,7 @@ re_node_set_alloc (re_node_set *set, Idx size) set->alloc = size; set->nelem = 0; set->elems = re_malloc (Idx, size); - if (BE (set->elems == NULL, 0)) + if (BE (set->elems == NULL, 0) && (MALLOC_0_IS_NONNULL || size != 0)) return REG_ESPACE; return REG_NOERROR; } |