summaryrefslogtreecommitdiffstats
path: root/usr.sbin/iostat/iostat.c
diff options
context:
space:
mode:
authorjedgar <jedgar@FreeBSD.org>2000-12-01 12:02:16 +0000
committerjedgar <jedgar@FreeBSD.org>2000-12-01 12:02:16 +0000
commit24771a5a3c2ba89e3afb649345fb8b30af12f94a (patch)
treea896a86f554d5778ea4ab61baae7bffc71f0ed23 /usr.sbin/iostat/iostat.c
parente3960a89e4a021190b2db9896ea16ce361c17ff6 (diff)
downloadFreeBSD-src-24771a5a3c2ba89e3afb649345fb8b30af12f94a.zip
FreeBSD-src-24771a5a3c2ba89e3afb649345fb8b30af12f94a.tar.gz
Properly check malloc(3) return values
Approved by: ken
Diffstat (limited to 'usr.sbin/iostat/iostat.c')
-rw-r--r--usr.sbin/iostat/iostat.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/usr.sbin/iostat/iostat.c b/usr.sbin/iostat/iostat.c
index bfcf773..6568824 100644
--- a/usr.sbin/iostat/iostat.c
+++ b/usr.sbin/iostat/iostat.c
@@ -285,8 +285,12 @@ main(int argc, char **argv)
if ((num_devices = getnumdevs()) < 0)
err(1, "can't get number of devices");
- cur.dinfo = (struct devinfo *)malloc(sizeof(struct devinfo));
- last.dinfo = (struct devinfo *)malloc(sizeof(struct devinfo));
+ if ((cur.dinfo = (struct devinfo *)malloc(sizeof(struct devinfo))) ==
+ NULL)
+ err(1, "devinfo malloc failed");
+ if ((last.dinfo = (struct devinfo *)malloc(sizeof(struct devinfo))) ==
+ NULL)
+ err(1, "devinfo malloc failed");
bzero(cur.dinfo, sizeof(struct devinfo));
bzero(last.dinfo, sizeof(struct devinfo));
@@ -305,7 +309,8 @@ main(int argc, char **argv)
* If the user specified any devices on the command line, see if
* they are in the list of devices we have now.
*/
- specified_devices = (char **)malloc(sizeof(char *));
+ if ((specified_devices = (char **)malloc(sizeof(char *))) == NULL)
+ err(1, "specified_devices malloc failed");
for (num_devices_specified = 0; *argv; ++argv) {
if (isdigit(**argv))
break;
OpenPOWER on IntegriCloud