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:
eadler 2012-11-15 15:06:18 +00:00
parent 413379c5a8
commit 23382e4b50

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