asprintf returns -1, not an arbitrary value < 0. Also upon error the

(very sloppy specification) leaves an undefined value in *ret, so it is
wrong to inspect it, the error condition is enough.

Obtained from:	OpenBSD
MFC after:	3 days
This commit is contained in:
Baptiste Daroussin 2020-01-14 08:18:04 +00:00
parent a3337141a4
commit f9eac42577

View File

@ -1,4 +1,4 @@
/* $OpenBSD: xmalloc.c,v 1.9 2015/11/17 18:25:02 tobias Exp $ */
/* $OpenBSD: xmalloc.c,v 1.10 2019/06/28 05:44:09 deraadt Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@ -81,7 +81,7 @@ xasprintf(char **ret, const char *fmt, ...)
i = vasprintf(ret, fmt, ap);
va_end(ap);
if (i < 0 || *ret == NULL)
if (i == -1)
err(2, "xasprintf");
return i;