Date: Fri, 22 Mar 2002 00:50:02 -0800 (PST) From: Maxim Konovalov <maxim@macomnet.ru> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/36175: Vsnprintf causes memeory leak Message-ID: <200203220850.g2M8o2d86832@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/36175; it has been noted by GNATS.
From: Maxim Konovalov <maxim@macomnet.ru>
To: Jiu Zheng <jiu@stbernard.com>
Cc: freebsd-gnats-submit@FreeBSD.ORG, <assar@FreeBSD.ORG>
Subject: Re: bin/36175: Vsnprintf causes memeory leak
Date: Fri, 22 Mar 2002 11:42:55 +0300 (MSK)
Could you please try a patch below (from OpenBSD):
Index: vsnprintf.c
===================================================================
RCS file: /home/ncvs/src/lib/libc/stdio/vsnprintf.c,v
retrieving revision 1.15
diff -u -r1.15 vsnprintf.c
--- vsnprintf.c 18 Jun 2001 04:40:52 -0000 1.15
+++ vsnprintf.c 22 Mar 2002 08:32:29 -0000
@@ -55,6 +55,7 @@
{
size_t on;
int ret;
+ char dummy;
FILE f;
on = n;
@@ -62,6 +63,11 @@
n--;
if (n > INT_MAX)
n = INT_MAX;
+ /* Stdio internals do not deal correctly with zero length buffer */
+ if (n == 0) {
+ str = &dummy;
+ n = 1;
+ }
f._file = -1;
f._flags = __SWR | __SSTR;
f._bf._base = f._p = (unsigned char *)str;
%%%
--
Maxim Konovalov, MAcomnet, Internet-Intranet Dept., system engineer
phone: +7 (095) 796-9079, mailto:maxim@macomnet.ru
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200203220850.g2M8o2d86832>
