aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Somers <asomers@FreeBSD.org>2025-09-09 16:29:34 +0000
committerAlan Somers <asomers@FreeBSD.org>2025-09-09 16:45:17 +0000
commit9bfbc6826f72eb385bf52f4cde8080bccf7e3ebd (patch)
tree100e5af8785965a2748d886d7cd4ee289ce25ada
parentfaf7e99375910fadb1b409a756be5477b561a517 (diff)
sockstat: fix the -j option with piped output after libxo integration
The legacy code handling -j in display() was causing xo_finish() to be skipped. It has also been causing a memory leak since 0726c6574f8 (sockstat: Add automatic column sizing and remove -w option) Fixes: 7b35b4d1963 (sockstat: add libxo support) MFC after: 1 week Reported by: glebius Reviewed by: glebius Sponsored by: ConnectWise Pull Request: https://github.com/freebsd/freebsd-src/pull/1842
-rw-r--r--usr.bin/sockstat/main.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/usr.bin/sockstat/main.c b/usr.bin/sockstat/main.c
index b5e0248b743a..2e75e4966d80 100644
--- a/usr.bin/sockstat/main.c
+++ b/usr.bin/sockstat/main.c
@@ -1612,7 +1612,7 @@ display(void)
}
}
if (opt_j >= 0)
- return;
+ goto out;
SLIST_FOREACH(s, &nosocks, socket_list) {
if (!check_ports(s))
continue;
@@ -1637,6 +1637,7 @@ display(void)
display_sock(s, &cw, buf, bufsize);
xo_close_instance("socket");
}
+out:
xo_close_list("socket");
xo_close_container("sockstat");
if (xo_finish() < 0)