From owner-freebsd-bugs Fri Mar 22 12:10:24 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 9390F37B400 for ; Fri, 22 Mar 2002 12:10:02 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g2MKA2S85971; Fri, 22 Mar 2002 12:10:02 -0800 (PST) (envelope-from gnats) Date: Fri, 22 Mar 2002 12:10:02 -0800 (PST) Message-Id: <200203222010.g2MKA2S85971@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Jiu Zheng Subject: Re: bin/36175: Vsnprintf causes memeory leak Reply-To: Jiu Zheng Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org The following reply was made to PR bin/36175; it has been noted by GNATS. From: Jiu Zheng To: Maxim Konovalov Cc: , 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