From 41adf21f1fde09a07054cd9daa096b7212ab2b7c Mon Sep 17 00:00:00 2001
From: assar <assar@FreeBSD.org>
Date: Sat, 16 Jun 2001 05:37:57 +0000
Subject: free memory that gets allocated by vfprintf when str == NULL

PR:		misc/26044

MFC after:	1 week
---
 lib/libc/stdio/sprintf.c | 2 ++
 1 file changed, 2 insertions(+)

(limited to 'lib/libc/stdio/sprintf.c')

diff --git a/lib/libc/stdio/sprintf.c b/lib/libc/stdio/sprintf.c
index a810096..04910e0 100644
--- a/lib/libc/stdio/sprintf.c
+++ b/lib/libc/stdio/sprintf.c
@@ -77,5 +77,7 @@ sprintf(str, fmt, va_alist)
 	ret = __vfprintf(&f, fmt, ap);
 	va_end(ap);
 	*f._p = 0;
+	if (str == NULL)
+		free(f._bf._base);
 	return (ret);
 }
-- 
cgit v1.1