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 <y...@cs.hut.fi>
  * Copyright (c) 1995 Tatu Ylonen <y...@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;
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to