HomeFreeBSD

systat: Fix a bunch of use after frees in fetch_ifstat().

Description

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

(cherry picked from commit f6fdf9214a657351e78c68aac1888e674c0481f6)

Details

Provenance
jhbAuthored on Nov 22 2022, 7:11 PM
Differential Revision
D36823: systat: Fix a bunch of use after frees in fetch_ifstat().
Parents
rG15347d162287: top(8): restore erronously removed SWAIT array element
Branches
Unknown
Tags
Unknown