This is the mail archive of the libc-hacker@sourceware.org mailing list for the glibc project.
Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
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.} */
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |