This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: asprintf() issue
- From: "Carlos O'Donell" <carlos at redhat dot com>
- To: Joseph Myers <joseph at codesourcery dot com>, Archie Cobbs <archie dot cobbs at gmail dot com>
- Cc: Florian Weimer <fweimer at redhat dot com>, libc-alpha at sourceware dot org, Michael Kerrisk-manpages <mtk dot manpages at gmail dot com>
- Date: Wed, 13 May 2015 13:12:20 -0400
- Subject: Re: asprintf() issue
- Authentication-results: sourceware.org; auth=none
- References: <CANSoFxt-cdc-+C4u-rTENMtY4X9RpRSuv+axDswSPxbDgag8_Q at mail dot gmail dot com> <55520F8F dot 9020308 at redhat dot com> <CANSoFxvac6_uBgwzWm5q6U+GcWzzKtDtDP0BVvE4eL08zXHs5Q at mail dot gmail dot com> <5552183C dot 2070809 at redhat dot com> <CANSoFxv7uO2Niq+wVKsC9xoDYuNgqHFxJnLrkgNqfKpFwzde=Q at mail dot gmail dot com> <alpine dot DEB dot 2 dot 10 dot 1505131601320 dot 30846 at digraph dot polyomino dot org dot uk>
On 05/13/2015 12:14 PM, Joseph Myers wrote:
> Does anyone know of implementations that do something other than leaving
> the value unchanged or setting it to NULL? The external specifications in
> question are LSB and TR 24731-2:2010 (which defers to LSB), and they seem
> to be silent on this issue.
Windows lacks asprintf, Solaris lacks asprintf, HPUX lacks asprintf,
so we have little guidance from these OSs.
I know of no other implementations that do something other than leave the
value unchanged or set to NULL.
My preference is that we set it to NULL. This will aid in debugging as any
dereferences to NULL will immediately trap. Leaving the value unchanged
could result in further manipulation of an invalid memory location and
program corruption.
This is in line with what the BSDs do, and therefore aids in porting code
between them.
So +1 to set it to NULL.
Cheers,
Carlos.