summaryrefslogtreecommitdiff
path: root/buf.c
diff options
context:
space:
mode:
Diffstat (limited to 'buf.c')
-rw-r--r--buf.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/buf.c b/buf.c
index 33a5a9f..c051295 100644
--- a/buf.c
+++ b/buf.c
@@ -74,6 +74,8 @@ struct Buf *buf_prints (struct Buf *buf, const char *fmt, const char *s)
size_t tsz;
t = flex_alloc (tsz = strlen (fmt) + strlen (s) + 1);
+ if (!t)
+ flexfatal (_("Allocation of buffer to print string failed"));
snprintf (t, tsz, fmt, s);
buf = buf_strappend (buf, t);
flex_free (t);
@@ -92,6 +94,8 @@ struct Buf *buf_linedir (struct Buf *buf, const char* filename, int lineno)
size_t tsz;
t = flex_alloc (tsz = strlen (fmt) + strlen (filename) + (int)(1 + log10(lineno>=0?lineno:-lineno)) + 1);
+ if (!t)
+ flexfatal (_("Allocation of buffer for line directive failed"));
snprintf (t, tsz, fmt, lineno, filename);
buf = buf_strappend (buf, t);
flex_free (t);
@@ -162,6 +166,8 @@ struct Buf *buf_m4_define (struct Buf *buf, const char* def, const char* val)
val = val?val:"";
str = (char*)flex_alloc(strsz = strlen(fmt) + strlen(def) + strlen(val) + 2);
+ if (!str)
+ flexfatal (_("Allocation of buffer for m4 def failed"));
snprintf(str, strsz, fmt, def, val);
buf_append(buf, &str, 1);
@@ -180,6 +186,8 @@ struct Buf *buf_m4_undefine (struct Buf *buf, const char* def)
size_t strsz;
str = (char*)flex_alloc(strsz = strlen(fmt) + strlen(def) + 2);
+ if (!str)
+ flexfatal (_("Allocation of buffer for m4 undef failed"));
snprintf(str, strsz, fmt, def);
buf_append(buf, &str, 1);