HomeFreeBSD

libpfctl: fix memory leak

Description

libpfctl: fix memory leak

When we snl_init_writer() we allocate memory in the struct snl_state in the struct pfctl_handle.
This memory was never released again, leading to a memory leak. We still
had a reference to the memory and would release it on pfctl_close()
(so valgrind did not detect it as a leak), but long-lived users (e.g.
bsnmpd) would eventually run out of memory.

Explicitly reset the snl_state when we're done to prevent this.

MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")

Details

Provenance
kpAuthored on Jun 11 2026, 2:58 PM
Parents
rG2a478dfc7f9c: libpfctl: retrieve family id only once
Branches
Unknown
Tags
Unknown