]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
HTSP: Plug possible memory leak at HTSP disconnect
authorAndreas Öman <andreas@lonelycoder.com>
Thu, 8 Nov 2012 13:21:39 +0000 (14:21 +0100)
committerAndreas Öman <andreas@lonelycoder.com>
Thu, 8 Nov 2012 13:21:39 +0000 (14:21 +0100)
If subscriber is slow we will leak memory because buffered packets
will not be free'd upon HTSP session close

src/htsp_server.c

index 8fcbdd415266400e55dcbe4dbb8c278145dcc145..b8c75be4c343811f1ba0557ee4ef897c65a20bd4 100644 (file)
@@ -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);
 }