malloc() sets errno to ENOMEM already.
Submitted by: Christoph Mallon <christoph.mallon@gmx.de>
This commit is contained in:
parent
167145a17d
commit
d00489b70f
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=244778
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user