]> git.ipfire.org Git - thirdparty/rspamd.git/commit
[Fix] Fix memory leak in address parsing for *-any addresses
authorVsevolod Stakhov <vsevolod@rspamd.com>
Tue, 28 Oct 2025 15:01:21 +0000 (15:01 +0000)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Tue, 28 Oct 2025 15:01:21 +0000 (15:01 +0000)
commit6bfa590be3d7d0794641e2e9c9c35715b7fdad98
tree08081a3ed6b0e3900a46dac5e3e4a66817f565a1
parent20bdd0ce2137458d23a84fcfbe4de16a4e6ed152
[Fix] Fix memory leak in address parsing for *-any addresses

In rspamd_parse_host_port_priority(), when handling '*' (any address),
the GPtrArray was created with a conditional destructor:

    pool == NULL ? NULL : (GDestroyNotify) rspamd_inet_address_free

This meant that when pool == NULL, the array had NO destructor for
elements. Later, when rspamd_upstreams_add_upstream() copied addresses
and called g_ptr_array_free(addrs, TRUE), the original address objects
were not freed, causing a memory leak.

Fix: Always set the destructor to rspamd_inet_address_free, regardless
of pool presence. The destructor will properly free address elements
when the array is freed, while mempool destructor (if pool exists)
will handle freeing the array itself.
src/libutil/addr.c