chiark / gitweb /
fileio: fix MIN/MAX mixup (#3896)
authorVito Caputo <vcaputo@gnugeneration.com>
Fri, 5 Aug 2016 04:09:23 +0000 (21:09 -0700)
committerSven Eden <yamakuzure@gmx.net>
Wed, 5 Jul 2017 06:50:50 +0000 (08:50 +0200)
The intention is to clamp the value to READ_FULL_BYTES_MAX, which
would be the minimum of the two.

src/basic/fileio.c

index 16a6d02..88fd7d0 100644 (file)
@@ -271,7 +271,7 @@ int read_full_stream(FILE *f, char **contents, size_t *size) {
                 if (n >= READ_FULL_BYTES_MAX)
                         return -E2BIG;
 
-                n = MAX(n * 2, READ_FULL_BYTES_MAX);
+                n = MIN(n * 2, READ_FULL_BYTES_MAX);
         }
 
         buf[l] = 0;