Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 31 May 2002 03:38:42 +1000 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        mm <meadele@nerim.net>
Cc:        freebsd-bugs@FreeBSD.ORG
Subject:   Re: snprintf() bug ?
Message-ID:  <20020531033520.B30078-100000@gamplex.bde.org>
In-Reply-To: <3CF689F0.9060904@nerim.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 30 May 2002, mm wrote:

>   int ln;
>   char *a_stuff = "hello";
>   char *b_stuff = "world";
>
>   while( 1 )
>       ln = snprintf(NULL, 0, "%s=%s", a_stuff, b_stuff);
>
> This result in memory leak, BUT if I use:
>
>   char buf[1];
>   int ln;
>   char *a_stuff = "hello";
>   char *b_stuff = "world";
>
>   while( 1 )
>       ln = snprintf(buf, 0, "%s=%s", a_stuff, b_stuff);
>
> No memory leak.
>
> Is this a snprintf() bug, or am i doing something wrong ?
> I'm using FreeBSD-4.4.

It is an snprintf() bug.  See PR 26044.  It is still not fixed.  An
attempted fix was committed and backed out almost a year ago.

Bruce


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?20020531033520.B30078-100000>