git: bdb205c53ed7 - main - libpfctl: fix memory leak in pfctl_get_status()

From: Kristof Provost <kp_at_FreeBSD.org>
Date: Wed, 01 Oct 2025 12:18:55 UTC
The branch main has been updated by kp:

URL: https://cgit.FreeBSD.org/src/commit/?id=bdb205c53ed769ad9f5e8da1ec6d05c48992dbf8

commit bdb205c53ed769ad9f5e8da1ec6d05c48992dbf8
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2025-10-01 09:41:25 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2025-10-01 12:09:39 +0000

    libpfctl: fix memory leak in pfctl_get_status()
    
    Remember to also free ncounters.
    
    Fixes:          c00aca9a71 ("pf: Show pf fragment reassembly counters.")
    MFC after:      3 days
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
---
 lib/libpfctl/libpfctl.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c
index 4b579de38ad0..8c4b26b98054 100644
--- a/lib/libpfctl/libpfctl.c
+++ b/lib/libpfctl/libpfctl.c
@@ -561,6 +561,10 @@ pfctl_free_status(struct pfctl_status *status)
 		free(c->name);
 		free(c);
 	}
+	TAILQ_FOREACH_SAFE(c, &status->ncounters, entry, tmp) {
+		free(c->name);
+		free(c);
+	}
 
 	free(status);
 }