From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11581 invoked by alias); 25 Jan 2006 05:49:40 -0000 Received: (qmail 11565 invoked by uid 22791); 25 Jan 2006 05:49:40 -0000 X-Spam-Check-By: sourceware.org Received: from www.gniibe.org (HELO zanshin.gniibe.org) (192.47.44.103) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 25 Jan 2006 05:49:37 +0000 Received: from [202.53.187.9] (helo=[10.4.250.244]) by zanshin.gniibe.org with esmtpsa (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1F1dXB-0000dm-Lc; Wed, 25 Jan 2006 14:49:33 +0900 Message-ID: <43D71150.7080002@m17n.org> Date: Wed, 25 Jan 2006 05:49:00 -0000 From: NIIBE Yutaka User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) MIME-Version: 1.0 To: Glibc hackers Subject: snprintf documentation fix Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Mailing-List: contact libc-hacker-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sourceware.org X-SW-Source: 2006-01/txt/msg00094.txt.bz2 Hi there, I found a bug in the example code of snprintf in the documentation. It explains as follows: Function snprintf returns number of characters needed to output. Using that value, it reallocates buffer and calls snprintf again. However, second call of snprintf has same argument for SIZE even though the buffer has bigger size. How about following change? Index: manual/stdio.texi =================================================================== RCS file: /cvs/glibc/libc/manual/stdio.texi,v retrieving revision 1.135 diff -u -3 -p -r1.135 stdio.texi --- manual/stdio.texi 15 Dec 2005 22:30:34 -0000 1.135 +++ manual/stdio.texi 25 Jan 2006 05:11:08 -0000 @@ -2357,7 +2357,8 @@ make_message (char *name, char *value) @{ /* @r{Reallocate buffer now that we know how much space is needed.} */ - buffer = (char *) xrealloc (buffer, nchars + 1); + size = nchars + 1; + buffer = (char *) xrealloc (buffer, size); if (buffer != NULL) /* @r{Try again.} */