From: Gurusamy Sarathy Date: Wed, 2 Jun 1999 07:16:10 +0000 (+0000) Subject: avoid dereferencing null pointer from getpwent() et al X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=eff96b52edf00b5721cd2c3b90d509f4653dd1be;p=p5sagit%2Fp5-mst-13.2.git avoid dereferencing null pointer from getpwent() et al p4raw-id: //depot/perl@3519 --- diff --git a/pp_sys.c b/pp_sys.c index dd588ec..054645e 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -4556,7 +4556,7 @@ PP(pp_gpwent) struct passwd *pwent; STRLEN n_a; #ifdef HAS_GETSPENT - struct spwd *spwent; + struct spwd *spwent = NULL; #endif if (which == OP_GPWNAM) @@ -4567,14 +4567,18 @@ PP(pp_gpwent) pwent = (struct passwd *)getpwent(); #ifdef HAS_GETSPNAM - if (which == OP_GPWNAM) - spwent = getspnam(pwent->pw_name); + if (which == OP_GPWNAM) { + if (pwent) + spwent = getspnam(pwent->pw_name); + } # ifdef HAS_GETSPUID /* AFAIK there isn't any anywhere. --jhi */ - else if (which == OP_GPWUID) - spwent = getspnam(pwent->pw_name); + else if (which == OP_GPWUID) { + if (pwent) + spwent = getspnam(pwent->pw_name); + } # endif - else - spwent = (struct spwd *)getspent(); + else + spwent = (struct spwd *)getspent(); #endif EXTEND(SP, 10);