summaryrefslogtreecommitdiff
path: root/regex/reginit.c
diff options
context:
space:
mode:
Diffstat (limited to 'regex/reginit.c')
-rw-r--r--regex/reginit.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/regex/reginit.c b/regex/reginit.c
index b5815e7d01c..309685fadf2 100644
--- a/regex/reginit.c
+++ b/regex/reginit.c
@@ -1,6 +1,6 @@
/* Init cclasses array from ctypes */
-#include <global.h>
+#include <my_global.h>
#include <m_ctype.h>
#include <m_string.h>
#include "cclass.h"
@@ -49,6 +49,16 @@ void regex_init()
for (i=0; i < CCLASS_LAST ; i++)
{
char *tmp=(char*) malloc(count[i]+1);
+ if (!tmp)
+ {
+ /*
+ This is very unlikely to happen as this function is called once
+ at program startup
+ */
+ fprintf(stderr,
+ "Fatal error: Can't allocate memory in regex_init\n");
+ exit(1);
+ }
memcpy(tmp,buff[i],count[i]*sizeof(char));
tmp[count[i]]=0;
cclasses[i].chars=tmp;
@@ -63,7 +73,7 @@ void regex_end()
{
int i;
for (i=0; i < CCLASS_LAST ; i++)
- free(cclasses[i].chars);
+ free((char*) cclasses[i].chars);
regex_inited=0;
}
}