perf_counter tools: Fix strbuf_fread() error path handling
authorRoel Kluin <roel.kluin@gmail.com>
Mon, 22 Jun 2009 16:42:33 +0000 (18:42 +0200)
committerIngo Molnar <mingo@elte.hu>
Wed, 24 Jun 2009 08:22:06 +0000 (10:22 +0200)
size_t res cannot be less than 0 - fread returns 0 on error.

[ Updated by: RenĂ© Scharfe <rene.scharfe@lsrfire.ath.cx> ]

Reported-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Junio C Hamano <gitster@pobox.com>
LKML-Reference: <4A3FB479.2090902@lsrfire.ath.cx>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
tools/perf/util/strbuf.c

index eaba0930680233a6f682c2d7710a2eb7fa9daac8..464e7ca898cfe221eb78da21373324c90de076a0 100644 (file)
@@ -259,7 +259,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;
 }