Bug (?) in sprintf family?
Eric Blake
ebb9@byu.net
Sat May 10 20:09:00 GMT 2008
Jeff Johnston <jjohnstn <at> redhat.com> writes:
> >> set, __sprint_r must allocate a string even if it will not be populating
it,
It turns out that on generating the empty string, __sprint_r is not even called.
> > Yep. The old __sprint_r calls __sfvwrite_r calls cantwrite calls
__smakebuf_r
> > which always mallocs a string the first time through asprintf,
The old _VFPRINTF_F also called cantwrite directly.
>
> Yes. Thanks for fixing this.
>
Hence I moved the STRING_ONLY malloc block into _VFPRINTF_R instead of
__sprint_r, then committed after actually testing the result via a rebuilt
cygwin. Sure enough, bash -c 'printf "%s" ""' no longer crashes.
--
Eric Blake
More information about the Newlib
mailing list