summaryrefslogtreecommitdiff
path: root/usr.bin/systat/vmstat.c
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2018-05-03 07:49:19 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2018-05-03 07:49:19 +0000
commit257bfdf21b7fd3340cd6c034f22afb51f9116ca8 (patch)
treeee01c12fa8a926a48f489d8396ef483b87f93b85 /usr.bin/systat/vmstat.c
parenta286b4c0579d57a3ceb8691417af18250fae97e1 (diff)
test for failing allocation using the standard idiom; prompted by Nan Xiao
ok tb@
Diffstat (limited to 'usr.bin/systat/vmstat.c')
-rw-r--r--usr.bin/systat/vmstat.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/usr.bin/systat/vmstat.c b/usr.bin/systat/vmstat.c
index f50aa502103..a515b73f958 100644
--- a/usr.bin/systat/vmstat.c
+++ b/usr.bin/systat/vmstat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vmstat.c,v 1.82 2016/12/18 23:36:32 krw Exp $ */
+/* $OpenBSD: vmstat.c,v 1.83 2018/05/03 07:49:18 otto Exp $ */
/* $NetBSD: vmstat.c,v 1.5 1996/05/10 23:16:40 thorpej Exp $ */
/*-
@@ -180,6 +180,8 @@ initvmstat(void)
intrloc = calloc(nintr, sizeof(long));
intrname = calloc(nintr, sizeof(char *));
+ if (intrloc == NULL || intrname == NULL)
+ err(2, NULL);
for (i = 0; i < nintr; i++) {
char name[128];
@@ -634,7 +636,7 @@ allocinfo(struct Info *si)
memset(si, 0, sizeof(*si));
si->intrcnt = calloc(nintr, sizeof(*si->intrcnt));
if (si->intrcnt == NULL)
- errx(2, "out of memory");
+ err(2, NULL);
}
static void