aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/systat
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2022-11-22 19:11:42 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2022-11-22 19:11:42 +0000
commitf6fdf9214a657351e78c68aac1888e674c0481f6 (patch)
tree732e4a1152fb3df5b1b0bcf8270b5a6776930b83 /usr.bin/systat
parentbee60c98974593d25aa18743f9413a78e0d57dc9 (diff)
downloadsrc-f6fdf9214a657351e78c68aac1888e674c0481f6.tar.gz
src-f6fdf9214a657351e78c68aac1888e674c0481f6.zip
systat: Fix a bunch of use after frees in fetch_ifstat().
I think this was probably just a typo. initifstat() continues around a similar loop if the mib data fails to fetch, and fetch_ifstat() was already using a FOREACH_SAFE loop here so expected to keep going. Calling clearifstat() from the fetch routine also seems wrong, and the sort_interface_list() call triggered by the existing needsort = 1 will itself set needclear to trigger a future clearifstat(). Reported by: GCC 12 -Wuse-after-free Differential Revision: https://reviews.freebsd.org/D36823
Diffstat (limited to 'usr.bin/systat')
-rw-r--r--usr.bin/systat/ifstat.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/usr.bin/systat/ifstat.c b/usr.bin/systat/ifstat.c
index c97e586ae7a3..3ac230c77561 100644
--- a/usr.bin/systat/ifstat.c
+++ b/usr.bin/systat/ifstat.c
@@ -290,7 +290,7 @@ fetchifstat(void)
SLIST_REMOVE(&curlist, ifp, if_stat, link);
free(ifp);
needsort = 1;
- clearifstat();
+ continue;
} else if (strcmp(ifp->dev_name, ifp->if_mib.ifmd_name) != 0 ) {
/* a device was removed and another one was added */
format_device_name(ifp);