summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2001-01-02 20:09:03 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2001-01-02 20:09:03 +0000
commite01e35fa3d88cbe1f5c30864377862a393ad1ee4 (patch)
tree23691b24c7d12ac8229612d1935da0dece85b779 /usr.bin
parent28aa656edf9b84e10b2d2edd658ea607f3d5b075 (diff)
check for another allocation failure
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/vmstat/dkstats.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/usr.bin/vmstat/dkstats.c b/usr.bin/vmstat/dkstats.c
index 7fda60a83a1..47066d407b6 100644
--- a/usr.bin/vmstat/dkstats.c
+++ b/usr.bin/vmstat/dkstats.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dkstats.c,v 1.8 2000/10/03 03:12:16 aaron Exp $ */
+/* $OpenBSD: dkstats.c,v 1.9 2001/01/02 20:09:02 deraadt Exp $ */
/* $NetBSD: dkstats.c,v 1.1 1996/05/10 23:19:27 thorpej Exp $ */
/*
@@ -219,9 +219,9 @@ int select;
cur.dk_select = calloc(dk_ndrive, sizeof(int));
cur.dk_name = calloc(dk_ndrive, sizeof(char *));
- if (!cur.dk_time || !cur.dk_xfer || !cur.dk_seek || !cur.dk_bytes
- || !last.dk_time || !last.dk_xfer || !last.dk_seek || !last.dk_bytes
- || !cur.dk_select || !cur.dk_name)
+ if (!cur.dk_time || !cur.dk_xfer || !cur.dk_seek || !cur.dk_bytes ||
+ !last.dk_time || !last.dk_xfer || !last.dk_seek ||
+ !last.dk_bytes || !cur.dk_select || !cur.dk_name)
errx(1, "Memory allocation failure.");
/* Set up the compatibility interfaces. */
@@ -235,6 +235,8 @@ int select;
deref_kptr(p, &cur_disk, sizeof(cur_disk));
deref_kptr(cur_disk.dk_name, buf, sizeof(buf));
cur.dk_name[i] = strdup(buf);
+ if (!cur.dk_name[i])
+ errx(1, "Memory allocation failure.");
cur.dk_select[i] = select;
p = cur_disk.dk_link.tqe_next;