]> rtime.felk.cvut.cz Git - git.git/commitdiff
fread does not return negative on error
authorRoel Kluin <roel.kluin@gmail.com>
Mon, 22 Jun 2009 16:42:33 +0000 (18:42 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 23 Jun 2009 23:57:15 +0000 (16:57 -0700)
size_t res cannot be less than 0. fread returns 0 on error.

Reported-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
strbuf.c

index a88496030b7053a543173c299bd9f54b923db2ec..f03d11702b3f6212ca7305df60f2f9ea6ca49e35 100644 (file)
--- a/strbuf.c
+++ b/strbuf.c
@@ -260,7 +260,7 @@ size_t strbuf_fread(struct strbuf *sb, size_t size, FILE *f)
        res = fread(sb->buf + sb->len, 1, size, f);
        if (res > 0)
                strbuf_setlen(sb, sb->len + res);
-       else if (res < 0 && oldalloc == 0)
+       else if (oldalloc == 0)
                strbuf_release(sb);
        return res;
 }