Make getarg return NULL if args is NULL

This commit is contained in:
Baptiste Daroussin 2015-07-12 00:02:43 +00:00
parent 52f92d8c1d
commit 8a2ace2a78
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=285415
2 changed files with 7 additions and 5 deletions

View File

@ -582,7 +582,12 @@ cmdhelp(int mode, int which)
struct carg *
getarg(struct cargs * _args, int ch)
{
struct carg *c = LIST_FIRST(_args);
struct carg *c;
if (_args == NULL)
return (NULL);
c = LIST_FIRST(_args);
while (c != NULL && c->ch != ch)
c = LIST_NEXT(c, list);

View File

@ -874,11 +874,8 @@ pw_gidpolicy(struct cargs * args, char *nam, gid_t prefer)
(grp->gr_mem == NULL || grp->gr_mem[0] == NULL)) {
gid = grp->gr_gid; /* Already created? Use it anyway... */
} else {
struct cargs grpargs;
gid_t grid = -1;
LIST_INIT(&grpargs);
/*
* We need to auto-create a group with the user's name. We
* can send all the appropriate output to our sister routine
@ -893,7 +890,7 @@ pw_gidpolicy(struct cargs * args, char *nam, gid_t prefer)
if (conf.dryrun) {
gid = pw_groupnext(cnf, true);
} else {
pw_group(M_ADD, nam, grid, &grpargs);
pw_group(M_ADD, nam, grid, NULL);
if ((grp = GETGRNAM(nam)) != NULL)
gid = grp->gr_gid;
}