]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
(read_file): Bug fix, in dependence on initial size on max_size.
authorNiels Möller <nisse@lysator.liu.se>
Thu, 7 Jul 2011 20:42:55 +0000 (22:42 +0200)
committerNiels Möller <nisse@lysator.liu.se>
Thu, 7 Jul 2011 20:42:55 +0000 (22:42 +0200)
Rev: nettle/examples/io.c:1.4

examples/io.c

index 689e0f6098d4e3d23b86b2ece2322b4bea4a085b..c24546f54f0cfa3b294b645b6988d33f4c06b0bb 100644 (file)
@@ -88,8 +88,13 @@ read_file(const char *name, unsigned max_size, char **contents)
     size = max_size;
   else
     size = 100;
-  
-  for (size = 100, done = 0;
+
+  /* FIXME: The use of feof and ferror in this loop is a bit confused
+     (but I think it is still correct). We should check the return
+     value of fread, and call feof and/or ferror when we get a short
+     item count. */    
+
+  for (done = 0;
        (!max_size || done < max_size) && !feof(f);
        size *= 2)
     {