On Fri, May 29, 2015 at 10:40:54AM -0700, Jon A. Cruz wrote:
> Yes. The man page calls out its behavior.
>
> http://linux.die.net/man/3/asprintf
>
> > Return Value
> > When successful, these functions return the number of bytes printed, just
> > like sprintf(3). If memory allocation wasn't possib
Yes. The man page calls out its behavior.
http://linux.die.net/man/3/asprintf
> Return Value
> When successful, these functions return the number of bytes printed, just
> like sprintf(3). If memory allocation wasn't possible, or some other error
> occurs, these functions will return -1, and the c
I can't find any standard for asprintf outside of the glibc library,
which doesn't mention anything about undefined behavior. Am I missing
something?
http://www.gnu.org/software/libc/manual/html_node/Dynamic-Output.html
On Fri, May 29, 2015 at 10:29 AM, Jon A. Cruz wrote:
> Well, no.
>
> It is c
Well, no.
It is clearly documented to be "undefined", so it is completely within
spec for it to be just about anything. One of the more likely bad
scenarios is that the call internally allocates a buffer, starts to use
it, hits some problem, then frees the buffer while leaving its address
in place
I'm pretty certain the only two things that can happen is that str is
unchanged or it is set to NULL. So presetting it to NULL would work.
On Thu, May 28, 2015 at 7:01 PM, Jon A. Cruz wrote:
> If asprintf fails for any reason, the contents of the pointer
> are undefined. While some platforms se
If asprintf fails for any reason, the contents of the pointer
are undefined. While some platforms set it to NULL, there is no
guarantee that all will.
This change adds a simple wrapper to ensure proper NULL results
on failure.
Signed-off-by: Jon A. Cruz
---
src/evdev-middle-button.c |