avoid null ptr deref, from glenn@sun
[unix-history] / usr / src / bin / csh / time.c
index 1e4c529..8cfc010 100644 (file)
@@ -1,5 +1,11 @@
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved.  The Berkeley Software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)time.c      4.6 (Berkeley) %G%";
+static char *sccsid = "@(#)time.c      5.3 (Berkeley) %G%";
 #endif
 
 #include "sh.h"
 #endif
 
 #include "sh.h"
@@ -41,13 +47,15 @@ donice(v)
        register char **v;
 {
        register char *cp;
        register char **v;
 {
        register char *cp;
+       int nval;
 
        v++, cp = *v++;
        if (cp == 0)
 
        v++, cp = *v++;
        if (cp == 0)
-               (void) setpriority(PRIO_PROCESS, 0, 4);
+               nval = 4;
        else if (*v == 0 && any(cp[0], "+-"))
        else if (*v == 0 && any(cp[0], "+-"))
-               (void) setpriority(PRIO_PROCESS, 0, 
-                   getpriority(PRIO_PROCESS, 0) + getn(cp));
+               nval = getn(cp);
+       (void) setpriority(PRIO_PROCESS, 0,
+               getpriority(PRIO_PROCESS, 0) + nval);
 }
 
 ruadd(ru, ru2)
 }
 
 ruadd(ru, ru2)