Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 22 Mar 2002 12:10:02 -0800 (PST)
From:      Jiu Zheng <jiu@stbernard.com>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/36175: Vsnprintf causes memeory leak 
Message-ID:  <200203222010.g2MKA2S85971@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: Jiu Zheng <jiu@stbernard.com>
To: Maxim Konovalov <maxim@macomnet.ru>
Cc: <freebsd-gnats-submit@FreeBSD.ORG>, <assar@FreeBSD.ORG>
Subject: Re: bin/36175: Vsnprintf causes memeory leak 
Date: Fri, 22 Mar 2002 11:59:16 -0800 (PST)

 Thank you, Maxim,
 
 The way your patch works is exactly how I fixed problems in my
 applications' source codes - call vsnprintf(&dummy, 1, fmt, ap).
 
 The things is that it is impractical to patch and recompile libc for all
 our development workstations. I just wish this will get fixed soon with
 freebsd release.
 
 Jiu
 
 
 On Fri, 22 Mar 2002, Maxim Konovalov wrote:
 
 >
 > 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?200203222010.g2MKA2S85971>