Only main() calls pr_args() in L330 with ep->kp as argument which in
turn is set in L257 or L266 for every utmp entry. kp is checked against
NULL already in L229.

Even if kp was somehow NULL chances are high we'd fail before pr_args()
was called anyway since L244, L256 and L265 would then cause a NULL pointer
dereference. In fact, proc_compare() even expects its second argument to
to be not NULL (only the first one is checked explicitly).

Not that crashing is guaranteed upon undefined behaviour but noone
seems to have reported failure within the last 13 years, so I think it's
safe to remove that check.

Feedback? Comments?

Index: w.c
===================================================================
RCS file: /cvs/src/usr.bin/w/w.c,v
retrieving revision 1.62
diff -u -p -r1.62 w.c
--- w.c 30 May 2017 15:10:48 -0000      1.62
+++ w.c 26 Jul 2017 00:20:04 -0000
@@ -383,8 +383,6 @@ pr_args(struct kinfo_proc *kp)
        char **argv, *str;
        int left;
 
-       if (kp == NULL)
-               goto nothing;           /* XXX - can this happen? */
        left = argwidth;
        argv = kvm_getargv(kd, kp, argwidth+60);  /* +60 for ftpd snip */
        if (argv == NULL)

Reply via email to