This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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: asprintf() issue


On 05/13/2015 01:22 PM, Rich Felker wrote:
> On Wed, May 13, 2015 at 12:18:11PM -0500, Archie Cobbs wrote:
>> diff --git a/manual/stdio.texi b/manual/stdio.texi
>> index e407170..251c2bd 100644
>> --- a/manual/stdio.texi
>> +++ b/manual/stdio.texi
>> @@ -2551,6 +2551,8 @@ The return value is the number of characters
>> allocated for the buffer, or
>>  less than zero if an error occurred.  Usually this means that the buffer
>>  could not be allocated.
>>
>> +If an error occurs, *@var{ptr} is set to @code{NULL}.
>> +
>>  Here is how to use @code{asprintf} to get the same result as the
>>  @code{snprintf} example, but more easily:
> 
> Unless we're going to have a new symbol version that guarantees this
> behavior, I think it would make sense to document that the behavior
> used to be leaving it unchanged, and that programs intended to work
> with a range of glibc versions (or other implementations) should
> explicitly set ptr to NULL before making the call or refrain from
> inspecting it after a non-successful call.

Agreed.

I would also like to see an attempt at a test case that used setrlimit
to restrict the available address space, followed by using asprintf
on a large string. This should be semi-portable across all the supported
machines.

Cheers,
Carlos.


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