Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 28 Dec 2012 20:21:14 +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: r244778 - head/lib/libutil
Message-ID:  <201212282021.qBSKLEeG096326@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bapt
Date: Fri Dec 28 20:21:14 2012
New Revision: 244778
URL: http://svnweb.freebsd.org/changeset/base/244778

Log:
  malloc() sets errno to ENOMEM already.
  
  Submitted by:	Christoph Mallon <christoph.mallon@gmx.de>

Modified:
  head/lib/libutil/gr_util.c

Modified: head/lib/libutil/gr_util.c
==============================================================================
--- head/lib/libutil/gr_util.c	Fri Dec 28 20:19:54 2012	(r244777)
+++ head/lib/libutil/gr_util.c	Fri Dec 28 20:21:14 2012	(r244778)
@@ -505,17 +505,13 @@ gr_add(struct group *gr, char *newmember
 	}
 	/* Allocate enough for current pointers + 1 more and NULL marker */
 	mlen = (num_mem + 2) * sizeof(*gr->gr_mem);
-	if ((members = malloc(mlen)) == NULL) {
+	if ((members = malloc(mlen)) == NULL)
 		errno = ENOMEM;
-		return (NULL);
-	}
 	memcpy(members, gr->gr_mem, num_mem * sizeof(*gr->gr_mem));
 	members[num_mem++] = newmember;
 	members[num_mem] = NULL;
 	gr->gr_mem = members;
 	newgr = gr_dup(gr);
-	if (newgr == NULL)
-		errno = ENOMEM;
 	free(members);
 	return (newgr);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201212282021.qBSKLEeG096326>