--- regcomp.c.orig	2015-04-10 16:17:40.579684242 -0700
+++ regcomp.c	2015-04-10 16:19:14.432612466 -0700
@@ -894,6 +894,8 @@
       break;
 
   dfa->state_table = calloc (sizeof (struct re_state_table_entry), table_size);
+  if (BE (dfa->state_table == NULL, 0)) /* couldn't allocate memory, now what? */
+    return REG_ESPACE;
   dfa->state_hash_mask = table_size - 1;
 
   dfa->mb_cur_max = MB_CUR_MAX;
