From 7d5bbbe355add9c0be6e56c06f1818bf2448d48c Mon Sep 17 00:00:00 2001 From: deraadt Date: Fri, 28 Jun 2019 05:44:09 +0000 Subject: 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. discussed a little with nicm, and then much more with millert until we were exasperated --- usr.bin/diff/xmalloc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'usr.bin/diff/xmalloc.c') diff --git a/usr.bin/diff/xmalloc.c b/usr.bin/diff/xmalloc.c index a17c3fe5783..ce0f4545aee 100644 --- a/usr.bin/diff/xmalloc.c +++ b/usr.bin/diff/xmalloc.c @@ -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 * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -78,7 +78,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; -- cgit v1.2.3-59-g8ed1b