Browse Source

This patch from Rik Faith <faith@alephnull.com> fixes a potentially
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!

Eric Andersen 22 years ago
parent
commit
3ec9b390db
1 changed files with 1 additions and 0 deletions
  1. 1 0
      libc/stdio/printf.c

+ 1 - 0
libc/stdio/printf.c

@@ -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);