From 28623dcfa979bacbbf338eb5ac32ae71fd9c4984 Mon Sep 17 00:00:00 2001 From: iphydf Date: Tue, 15 Mar 2022 17:17:40 +0000 Subject: [PATCH] fix: Eliminate memory leak in toxav. This happens when shutting down a toxav session when it still has some packets in its internal queue. It's not a serious leak and happens very rarely (1 in 300 runs of the toxav_many_test), but it can happen and long-running tox instances that start and end calls a lot would eventually discover this. --- toxav/rtp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/toxav/rtp.c b/toxav/rtp.c index d5f7ac7f..212dd774 100644 --- a/toxav/rtp.c +++ b/toxav/rtp.c @@ -710,6 +710,9 @@ void rtp_kill(RTPSession *session) LOGGER_DEBUG(session->m->log, "Terminated RTP session V3 work_buffer_list->next_free_entry: %d", (int)session->work_buffer_list->next_free_entry); + for (int8_t i = 0; i < session->work_buffer_list->next_free_entry; ++i) { + free(session->work_buffer_list->work_buffer[i].buf); + } free(session->work_buffer_list); free(session); }