common: add an extra check in autobuf_enlarge to avoid a compiler warning
authorFerry Huberts <ferry.huberts@pelagic.nl>
Thu, 20 Mar 2014 08:24:55 +0000 (09:24 +0100)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Thu, 20 Mar 2014 08:37:54 +0000 (09:37 +0100)
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
src/common/autobuf.c

index 886c4bd..d6ba6a8 100644 (file)
@@ -46,6 +46,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include <errno.h>
+#include <limits.h>
 
 
 static int autobuf_enlarge(struct autobuf *autobuf, int new_size);
@@ -83,6 +84,11 @@ static int
 autobuf_enlarge(struct autobuf *autobuf, int new_size)
 {
   new_size++;
+
+  if (autobuf->size >= INT_MAX) {
+    return -1;
+  }
+
   if (new_size > autobuf->size) {
     char *p;
     int roundUpSize = ROUND_UP_TO_POWER_OF_2(new_size, AUTOBUFCHUNK);