mpegts: fix memleak on tune

This commit is contained in:
Adam Sutton 2014-04-14 23:46:36 +01:00
parent fe06fb6fd5
commit f89856d049
3 changed files with 9 additions and 4 deletions

View 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) {

View 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);

View 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;