OSDN Git Service

Fix fwrite return value bug reported by Matthias Kilian <kili@outback.escape.de>.
authorManuel Novoa III <mjn3@codepoet.org>
Mon, 7 May 2001 20:17:35 +0000 (20:17 -0000)
committerManuel Novoa III <mjn3@codepoet.org>
Mon, 7 May 2001 20:17:35 +0000 (20:17 -0000)
libc/stdio/stdio.c

index a7dd8a3..d3732db 100644 (file)
@@ -512,12 +512,13 @@ off_t _uClibc_fwrite(const unsigned char *buf, off_t bytes, FILE *fp)
                }
        FFLUSH:
                /* If we get here, either buffer is full or we need to flush anyway. */
+               buf = fp->bufpos - (p - (unsigned char *)buf);
                p = NULL;
        }
        if (!p) {                                       /* buf == NULL means fflush */
                p = fp->bufstart;
                bytes = fp->bufpos - p;
-               buf = fp->bufpos = fp->bufwrite = p;
+               fp->bufpos = fp->bufwrite = p;
        } else if (fp->bufpos > fp->bufstart) { /* If there are buffered chars, */
                _uClibc_fwrite(NULL, 0, fp); /* write them. */
                if (ferror(fp)) {