]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
mpegts: fix memleak on tune
authorAdam Sutton <dev@adamsutton.me.uk>
Mon, 14 Apr 2014 22:46:36 +0000 (23:46 +0100)
committerAdam Sutton <dev@adamsutton.me.uk>
Mon, 14 Apr 2014 22:46:36 +0000 (23:46 +0100)
src/input/mpegts/iptv/iptv.c
src/input/mpegts/linuxdvb/linuxdvb_frontend.c
src/input/mpegts/tsfile/tsfile_input.c

index a610e852b0462f6bb3b0c88aa55320edfb689227..4fd059c101b37bfbe8b43fa6884ef5289017270c 100644 (file)
@@ -244,7 +244,7 @@ iptv_input_stop_mux ( mpegts_input_t *mi, mpegts_mux_instance_t *mmi )
   }
 
   /* Free memory */
-  free(im->mm_iptv_buffer.sb_data);
+  sbuf_free(&im->mm_iptv_buffer);
 
   /* Clear bw limit */
   LIST_FOREACH(mnl, &mi->mi_networks, mnl_mi_link) {
index d34a2d0c35b9344647384ca9bbe37db00348deee..e1a69beec6cd2e93507eb898231916ab1443a295 100644 (file)
@@ -636,7 +636,6 @@ linuxdvb_frontend_input_thread ( void *aux )
   int fullmux;
   tvhpoll_t *efd;
   sbuf_t sb;
-  sbuf_init_fixed(&sb, 18800);
 
   /* Get MMI */
   pthread_mutex_lock(&lfe->lfe_dvr_lock);
@@ -685,6 +684,9 @@ linuxdvb_frontend_input_thread ( void *aux )
   ev[1].fd = ev[1].data.fd = lfe->lfe_dvr_pipe.rd;
   tvhpoll_add(efd, ev, 2);
 
+  /* Allocate memory */
+  sbuf_init_fixed(&sb, 18800);
+
   /* Read */
   while (tvheadend_running) {
     nfds = tvhpoll_wait(efd, ev, 1, -1);
@@ -708,6 +710,7 @@ linuxdvb_frontend_input_thread ( void *aux )
     mpegts_input_recv_packets((mpegts_input_t*)lfe, mmi, &sb, 0, NULL, NULL);
   }
 
+  sbuf_free(&sb);
   tvhpoll_destroy(efd);
   if (dmx != -1) close(dmx);
   close(dvr);
index f6023ca74894178c05c407459acd3fc2a0a9ffc2..edf23d954c22cb8f75cede44423deaae1f276156 100644 (file)
@@ -52,8 +52,6 @@ tsfile_input_thread ( void *aux )
   mpegts_mux_instance_t *mmi;
   tsfile_mux_instance_t *tmi;
 
-  sbuf_init_fixed(&buf, 18800);
-
   /* Open file */
   pthread_mutex_lock(&global_lock);
 
@@ -76,6 +74,9 @@ tsfile_input_thread ( void *aux )
   ev.fd = ev.data.fd = mi->ti_thread_pipe.rd;
   tvhpoll_add(efd, &ev, 1);
 
+  /* Alloc memory */
+  sbuf_init_fixed(&buf, 18800);
+
   /* Get file length */
   if (fstat(fd, &st)) {
     tvhlog(LOG_ERR, "tsfile", "stat() failed %d (%s)",
@@ -168,6 +169,7 @@ tsfile_input_thread ( void *aux )
   }
 
 exit:
+  sbuf_free(&buf);
   tvhpoll_destroy(efd);
   close(fd);
   return NULL;