Avoid possible null deref if ypclnt_new returns null

PR:		bin/172979
Submitted by:	Erik Cederstrand <erik@cederstrand.dk>
Approved by:	cperciva
MFC after:	3 days
This commit is contained in:
Eitan Adler 2012-11-15 15:06:18 +00:00
parent d207a5583c
commit fd773ca3dd
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=243081

View File

@ -241,8 +241,11 @@ main(int argc, char *argv[])
#ifdef YP
case _PWF_NIS:
ypclnt = ypclnt_new(yp_domain, "passwd.byname", yp_host);
if (ypclnt == NULL ||
ypclnt_connect(ypclnt) == -1 ||
if (ypclnt == NULL) {
warnx("ypclnt_new failed");
exit(1);
}
if (ypclnt_connect(ypclnt) == -1 ||
ypclnt_passwd(ypclnt, pw, password) == -1) {
warnx("%s", ypclnt->error);
ypclnt_free(ypclnt);