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.
if (*addrs == NULL) {
*addrs = g_ptr_array_new_full(1,
- pool == NULL ? NULL : (GDestroyNotify) rspamd_inet_address_free);
+ (GDestroyNotify) rspamd_inet_address_free);
if (pool != NULL) {
rspamd_mempool_add_destructor(pool,