This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Bug (?) in sprintf family?


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




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]