瀏覽代碼

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 23 年之前
父節點
當前提交
3ec9b390db
共有 1 個文件被更改,包括 1 次插入0 次删除
  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);