Skip to content

Commit

Permalink
fread does not return negative on error
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Roel Kluin authored and Junio C Hamano committed Jun 23, 2009
1 parent 1ab012c commit 6651c3f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion strbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 6651c3f

Please sign in to comment.