Bug (?) in sprintf family?
Fri May 2 15:12:00 GMT 2008
Jeff Johnston <jjohnstn <at> redhat.com> writes:
> Please try the attached patch. It disconnects the sprintf and sscanf
> family of functions from bringing in all the I/O stuff. This is
> especially useful since tzset drags in sscanf.
> If I missed something, let me know.
With CVS cygwin, asprintf(&str, "%s", "") (or even simpler, asprintf(&str, ""))
currently dumps core, and I think the cause was this patch. Meanwhile,
asnprintf passes; and it looks like the only difference between them is that
you forgot to modify asnprintf.c to use the new _svfprintf_r instead of
_vfprintf_r, and that _vfprintf_r operating on a string correctly mallocs even
for an empty format string.
It seems like the fix would be making sure that in vfprintf.c, when __SMBF is
set, __sprint_r must allocate a string even if it will not be populating it,
since asprintf.c depends on the string being pre-allocated large enough to hold
the trailing NUL. But I'm still working on building a debugging version of
cygwin to test this theory.
More information about the Newlib