diff options
author | 2007-10-24 20:15:43 +0000 | |
---|---|---|
committer | 2007-10-24 20:15:43 +0000 | |
commit | 5da2e2b21c4ddc57bb5d26358e891d0774b5063a (patch) | |
tree | 81f79ada0cfdfd97c540fde77fcbbc95a58b94fc | |
parent | remove the unused i2cbus_attach_args param from the probe functions; ok deraadt (diff) | |
download | wireguard-openbsd-5da2e2b21c4ddc57bb5d26358e891d0774b5063a.tar.xz wireguard-openbsd-5da2e2b21c4ddc57bb5d26358e891d0774b5063a.zip |
add missing checks against NULL after realloc calls
Ok gilles@ moritz@
-rw-r--r-- | usr.bin/vmstat/dkstats.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/usr.bin/vmstat/dkstats.c b/usr.bin/vmstat/dkstats.c index b88eb2e0386..a700747b41e 100644 --- a/usr.bin/vmstat/dkstats.c +++ b/usr.bin/vmstat/dkstats.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dkstats.c,v 1.31 2007/10/23 07:35:58 chl Exp $ */ +/* $OpenBSD: dkstats.c,v 1.32 2007/10/24 20:15:43 chl Exp $ */ /* $NetBSD: dkstats.c,v 1.1 1996/05/10 23:19:27 thorpej Exp $ */ /* @@ -256,6 +256,15 @@ dkreadstats(void) dk_ndrive * sizeof(*last.dk_wbytes)); last.dk_time = realloc(last.dk_time, dk_ndrive * sizeof(*last.dk_time)); + + if (!cur.dk_select || !cur.dk_rxfer || + !cur.dk_wxfer || !cur.dk_seek || + !cur.dk_rbytes || !cur.dk_wbytes || + !cur.dk_time || !last.dk_rxfer || + !last.dk_wxfer || !last.dk_seek || + !last.dk_rbytes || !last.dk_wbytes || + !last.dk_time) + errx(1, "Memory allocation failure."); } else { cur.dk_select = realloc(cur.dk_select, dk_ndrive * sizeof(*cur.dk_select)); @@ -284,6 +293,15 @@ dkreadstats(void) last.dk_time = realloc(last.dk_time, dk_ndrive * sizeof(*last.dk_time)); + if (!cur.dk_select || !cur.dk_rxfer || + !cur.dk_wxfer || !cur.dk_seek || + !cur.dk_rbytes || !cur.dk_wbytes || + !cur.dk_time || !last.dk_rxfer || + !last.dk_wxfer || !last.dk_seek || + !last.dk_rbytes || !last.dk_wbytes || + !last.dk_time) + errx(1, "Memory allocation failure."); + for (i = dk_ndrive - 1, j = cur.dk_ndrive - 1; i >= 0; i--) { |