commit cc1288fba991ad4fe8b9d5fffe809565cb6c1585
parent d9866b46a35ac8ebf46db2ecbf1b7d62b9f88407
Author: Christoph Lohmann <20h@r-36.net>
Date:   Sat, 24 Feb 2018 13:30:29 +0100
Check for INT_MAX in case of variable allocation.
Diffstat:
1 file changed, 4 insertions(+), 0 deletions(-)
diff --git a/ind.c b/ind.c
@@ -15,6 +15,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <time.h>
+#include <limits.h>
 
 #include "ind.h"
 
@@ -136,6 +137,9 @@ smprintf(char *fmt, ...)
 	len = vsnprintf(NULL, 0, fmt, fmtargs);
 	va_end(fmtargs);
 
+	if (len == INT_MAX)
+		return NULL;
+
 	va_start(fmtargs, fmt);
 	ret = vsmprintf(fmt, fmtargs, len);
 	va_end(fmtargs);