OSDN Git Service

This patch from Rik Faith <faith@alephnull.com> fixes a potentially
authorEric Andersen <andersen@codepoet.org>
Tue, 11 Jun 2002 12:54:12 +0000 (12:54 -0000)
committerEric Andersen <andersen@codepoet.org>
Tue, 11 Jun 2002 12:54:12 +0000 (12:54 -0000)
non-NULL terminated string problem that could result from the use
of open_memstream().  Manuel may have a better solution, but this
one works for me, since with this plus the popen fix I can now run
things like gdb properly.  Thanks Rik!

libc/stdio/printf.c

index 92b5b59..e311a4f 100644 (file)
@@ -1451,6 +1451,7 @@ 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);