svn commit: r356724 - head/usr.bin/diff

Baptiste Daroussin bapt at FreeBSD.org
Tue Jan 14 08:18:05 UTC 2020


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 at cs.hut.fi>
  * Copyright (c) 1995 Tatu Ylonen <ylo at 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;


More information about the svn-src-all mailing list