Skip to content

Commit

Permalink
lib: Fix memory leak in snmp on shutdown
Browse files Browse the repository at this point in the history
The events list is storing a `struct event *` allocated
as a MTYPE_TMP pointer, on shutdown ensure that it is
properly free'd up.

Signed-off-by: Donald Sharp <[email protected]>
  • Loading branch information
donaldsharp committed Aug 11, 2024
1 parent 8cc8320 commit d60d830
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/agentx.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,19 @@ void smux_events_update(void)
agentx_events_update();
}

static void smux_events_delete_thread(void *arg)
{
struct event *e = arg;

event_cancel(&e);
XFREE(MTYPE_TMP, arg);
}

void smux_terminate(void)
{
if (events)
if (events) {
events->del = smux_events_delete_thread;
list_delete(&events);
}
}
#endif /* SNMP_AGENTX */

0 comments on commit d60d830

Please sign in to comment.