Date: Tue, 14 Jan 2020 08:18:05 +0000 (UTC) From: Baptiste Daroussin <bapt@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r356724 - head/usr.bin/diff Message-ID: <202001140818.00E8I5MI018636@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: bapt Date: Tue Jan 14 08:18:04 2020 New Revision: 356724 URL: https://svnweb.freebsd.org/changeset/base/356724 Log: 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 Modified: head/usr.bin/diff/xmalloc.c Modified: head/usr.bin/diff/xmalloc.c ============================================================================== --- head/usr.bin/diff/xmalloc.c Tue Jan 14 08:16:15 2020 (r356723) +++ head/usr.bin/diff/xmalloc.c Tue Jan 14 08:18:04 2020 (r356724) @@ -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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202001140818.00E8I5MI018636>