malloc() sets errno to ENOMEM already.

Submitted by:	Christoph Mallon <christoph.mallon@gmx.de>
This commit is contained in:
bapt 2012-12-28 20:21:14 +00:00
parent b69ff2af2f
commit 83035e8984

View File

@ -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);
}