aboutsummaryrefslogtreecommitdiff
path: root/src/backend/regex/regc_nfa.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/regex/regc_nfa.c')
-rw-r--r--src/backend/regex/regc_nfa.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/backend/regex/regc_nfa.c b/src/backend/regex/regc_nfa.c
index 06bbcae0ee3..4b19740788e 100644
--- a/src/backend/regex/regc_nfa.c
+++ b/src/backend/regex/regc_nfa.c
@@ -2229,9 +2229,12 @@ fixempties(struct nfa *nfa,
* current target state. totalinarcs is probably a considerable
* overestimate of the space needed, but the NFA is unlikely to be large
* enough at this point to make it worth being smarter.
+ *
+ * Note: totalinarcs could be zero, and some machines return NULL for
+ * malloc(0). Don't throw an error if so.
*/
arcarray = (struct arc **) MALLOC(totalinarcs * sizeof(struct arc *));
- if (arcarray == NULL)
+ if (arcarray == NULL && totalinarcs != 0)
{
NERR(REG_ESPACE);
FREE(inarcsorig);