summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlum <lum@cvs.openbsd.org>2010-04-21 11:30:00 +0000
committerlum <lum@cvs.openbsd.org>2010-04-21 11:30:00 +0000
commitdf71122422fb3534850dc8927f64c126a80aae22 (patch)
treec3343e5b9c946997815ab86dcfeb4da546193590
parentff7c3ba29b767fbf883d73aebef0e9d2cb70c401 (diff)
Handle a strdup failure.
ok otto@
-rw-r--r--usr.bin/top/top.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/usr.bin/top/top.c b/usr.bin/top/top.c
index b12836b76ba..36f02837735 100644
--- a/usr.bin/top/top.c
+++ b/usr.bin/top/top.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: top.c,v 1.73 2010/03/26 16:56:00 lum Exp $ */
+/* $OpenBSD: top.c,v 1.74 2010/04/21 11:29:59 lum Exp $ */
/*
* Top users/processes display for Unix
@@ -231,7 +231,9 @@ parseargs(int ac, char **av)
break;
case 'g': /* grep command name */
- ps.command = strdup(optarg);
+ free(ps.command);
+ if((ps.command = strdup(optarg)) == NULL);
+ err(1, NULL);
break;
default:
@@ -861,7 +863,9 @@ rundisplay(void)
tempbuf[1] == '\0')
ps.command = NULL;
else
- ps.command = strdup(tempbuf);
+ if((ps.command = strdup(tempbuf)) ==
+ NULL);
+ err(1, NULL);
putr();
} else
clear_message();