From 683b0f9c8bf4feaa0f3a17b1114b519005072e30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96man?= Date: Thu, 8 Nov 2012 14:21:39 +0100 Subject: [PATCH] HTSP: Plug possible memory leak at HTSP disconnect If subscriber is slow we will leak memory because buffered packets will not be free'd upon HTSP session close --- src/htsp_server.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/htsp_server.c b/src/htsp_server.c index 8fcbdd41..b8c75be4 100644 --- a/src/htsp_server.c +++ b/src/htsp_server.c @@ -1564,6 +1564,17 @@ htsp_serve(int fd, void *opaque, struct sockaddr_in *source, pthread_mutex_unlock(&htsp.htsp_out_mutex); pthread_join(htsp.htsp_writer_thread, NULL); + + htsp_msg_q_t *hmq; + + TAILQ_FOREACH(hmq, &htsp.htsp_active_output_queues, hmq_link) { + htsp_msg_t *hm; + while((hm = TAILQ_FIRST(&hmq->hmq_q)) != NULL) { + TAILQ_REMOVE(&hmq->hmq_q, hm, hm_link); + htsp_msg_destroy(hm); + } + } + close(fd); }