summaryrefslogtreecommitdiff
path: root/regex.c
diff options
context:
space:
mode:
authorwlestes <wlestes>2012-02-03 22:32:35 +0000
committerwlestes <wlestes>2012-02-03 22:32:35 +0000
commit0ece5566df239cfc380d927efd0a94fc71dd9f3e (patch)
tree66177f978d35a2e8e4da78933af8f315e8f18b09 /regex.c
parent48658c017179243b859cc3ddb01a9e0d58f8e451 (diff)
downloadflex-0ece5566df239cfc380d927efd0a94fc71dd9f3e.tar.gz
more better error messages; more better memory handling
Diffstat (limited to 'regex.c')
-rw-r--r--regex.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/regex.c b/regex.c
index 5533971..f5b9603 100644
--- a/regex.c
+++ b/regex.c
@@ -57,7 +57,9 @@ void flex_regcomp(regex_t *preg, const char *regex, int cflags)
const int errbuf_sz = 200;
char * errbuf=0;
- errbuf = (char*)flex_alloc(errbuf_sz *sizeof(char));
+ errbuf = (char*)flex_alloc(errbuf_sz *sizeof(char));
+ if (!errbuf)
+ flexfatal(_("Unable to allocate buffer to report regcomp failed"));
regerror (err, preg, errbuf, errbuf_sz);
snprintf (errbuf, errbuf_sz, "regcomp failed: %s\n", errbuf);
@@ -80,6 +82,8 @@ char *regmatch_dup (regmatch_t * m, const char *src)
return NULL;
len = m->rm_eo - m->rm_so;
str = (char *) flex_alloc ((len + 1) * sizeof (char));
+ if (!str)
+ flexfatal(_("Unable to allocate a copy of the match"));
strncpy (str, src + m->rm_so, len);
str[len] = 0;
return str;