提交 6651c3f7 编写于 作者: R Roel Kluin 提交者: Junio C Hamano

fread does not return negative on error

size_t res cannot be less than 0. fread returns 0 on error.
Reported-by: NIngo Molnar <mingo@elte.hu>
Signed-off-by: NRoel Kluin <roel.kluin@gmail.com>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 1ab012cf
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册