This is the mail archive of the
mailing list for the libstdc++ project.
Re: Debug mode output broken
Jonathan Wakely wrote:
First of all, please note that __n is not the buffer size here, it's thePlease have a look to the whole debug.cc: most of the times, according
to a very
length of the word to be copied. snprintf() is not used to prevent __buf
from being overflowed, it's used to prevent the whole of __s being copied.
common practice, snprintf is passed exactly __bufsize.
There is only *one* case, _M_print_string, where the second parameter of
is used for the other purpose that you are emphasizing above.
That's why we have a bug: someone replaced snprintf (when not available)
sprintf considering only the former uses of _M_format_word. We have to deal
correctly with the exception represented by _M_print_string.