[PATCH] fwrite: check fputc() result for EOF, not for != 0
Enrico Scholz <[email protected]> Sun, 26 Aug 2012 13:37:41 +0200
| Newsgroups | gmane.linux.lib.dietlibc |
|---|---|
| Message-ID | <1345981061-11651-1-git-send-email-enrico.scholz@informatik.tu-chemnitz.de> |
fputc() returns 'c' in normal case which triggered the error branch nearly everytime. Detected by the stdio/tst-fseek test. Signed-off-by: Enrico Scholz <[email protected]> --- libstdio/fwrite.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libstdio/fwrite.c b/libstdio/fwrite.c index 464abdd..9f4e8e5 100644 --- a/libstdio/fwrite.c +++ b/libstdio/fwrite.c @@ -49,7 +49,7 @@ notlinewise: } else done=0; for (i=done; i<len; ++i) - if (fputc_unlocked(((char*)ptr)[i],stream)) { + if (fputc_unlocked(((char*)ptr)[i],stream) == EOF) { res=len-i; goto abort; } -- 1.7.11.4