Date: Thu, 30 May 2002 20:22:08 +0000 From: mm <meadele@nerim.net> To: freebsd-bugs@freebsd.org Cc: meadele@nerim.net Subject: snprintf() bug ? Message-ID: <3CF689F0.9060904@nerim.net>
next in thread | raw e-mail | index | archive | help
Hello,
I hope i'm posting in the right place.
I was writting some piece of code, and just saw some big memory leak,
after inspecting my code I found that snprintf() was memory leaking.
I used this test code:
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.
Best regards,
Meadele Mathieu.
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?3CF689F0.9060904>
