OSDN Git Service

Revert Erik's patch to vasprintf and fix the real issue.
authorManuel Novoa III <mjn3@codepoet.org>
Tue, 11 Jun 2002 21:19:41 +0000 (21:19 -0000)
committerManuel Novoa III <mjn3@codepoet.org>
Tue, 11 Jun 2002 21:19:41 +0000 (21:19 -0000)
The writer for the stream returned by open_memstream was supposed to
keep the buffer nul-terminated.  I apparently left out a statement.

libc/stdio/printf.c
libc/stdio/stdio.c

index e311a4f..92b5b59 100644 (file)
@@ -1451,7 +1451,6 @@ int vasprintf(char **__restrict buf, const char * __restrict format,
                return -1;
        }
        rv = vfprintf(f, format, arg);
-       if (rv >= 0) fputc('\0', f);
        fclose(f);
        if (rv < 0) {
                free(*buf);
index 60d4fe7..1462874 100644 (file)
@@ -643,6 +643,7 @@ static ssize_t oms_write(void *cookie, const char *buf, size_t bufsize)
 
        if (COOKIE->pos > COOKIE->eof) {
                *COOKIE->sizeloc = COOKIE->eof = COOKIE->pos;
+               COOKIE->buf[COOKIE->eof] = 0; /* Need to nul-terminate. */
        }
 
        return bufsize;