Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
satip client: fix wrong memory access
  • Loading branch information
perexg committed Jun 1, 2016
1 parent 70c39f5 commit 1c0252c
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/input/mpegts/satip/satip_frontend.c
Expand Up @@ -1075,12 +1075,14 @@ satip_frontend_wake_other_waiting

static void
satip_frontend_request_cleanup
( satip_frontend_t *lfe, satip_tune_req_t *tr )
( satip_frontend_t *lfe, satip_tune_req_t **_tr )
{
satip_tune_req_t *tr = *_tr;
if (tr && tr != lfe->sf_req) {
mpegts_pid_done(&tr->sf_pids);
mpegts_pid_done(&tr->sf_pids_tuned);
free(tr);
*_tr = NULL;
}
if (tr == lfe->sf_req_thread)
lfe->sf_req_thread = NULL;
Expand Down Expand Up @@ -1149,7 +1151,7 @@ satip_frontend_extra_shutdown
static void
satip_frontend_shutdown
( satip_frontend_t *lfe, const char *name, http_client_t *rtsp,
satip_tune_req_t *tr, tvhpoll_t *efd )
satip_tune_req_t **tr, tvhpoll_t *efd )
{
char b[32];
tvhpoll_event_t ev;
Expand Down Expand Up @@ -1183,6 +1185,7 @@ satip_frontend_shutdown
sbuf_free(&lfe->sf_sbuf);

pthread_mutex_lock(&lfe->sf_dvr_lock);
satip_frontend_wake_other_waiting(lfe, *tr);
satip_frontend_request_cleanup(lfe, tr);
pthread_mutex_unlock(&lfe->sf_dvr_lock);
}
Expand Down Expand Up @@ -1218,7 +1221,7 @@ satip_frontend_close_rtsp
ev.data.ptr = NULL;
tvhpoll_rem(efd, &ev, 1);

satip_frontend_shutdown(lfe, name, *rtsp, *tr, efd);
satip_frontend_shutdown(lfe, name, *rtsp, tr, efd);

memset(&ev, 0, sizeof(ev));
ev.events = TVHPOLL_IN;
Expand All @@ -1227,9 +1230,7 @@ satip_frontend_close_rtsp
tvhpoll_add(efd, &ev, 1);

http_client_close(*rtsp);
satip_frontend_wake_other_waiting(lfe, *tr);
*rtsp = NULL;
*tr = NULL;
}

static int
Expand Down Expand Up @@ -1445,7 +1446,7 @@ satip_frontend_input_thread ( void *aux )
lfe->mi_display_name((mpegts_input_t*)lfe, buf, sizeof(buf));

pthread_mutex_lock(&lfe->sf_dvr_lock);
satip_frontend_request_cleanup(lfe, tr);
satip_frontend_request_cleanup(lfe, &tr);
lfe->sf_req_thread = tr = lfe->sf_req;
pthread_mutex_unlock(&lfe->sf_dvr_lock);

Expand Down Expand Up @@ -1896,10 +1897,9 @@ satip_frontend_input_thread ( void *aux )
tvhpoll_rem(efd, ev, nfds);

if (exit_flag) {
satip_frontend_shutdown(lfe, buf, rtsp, tr, efd);
satip_frontend_shutdown(lfe, buf, rtsp, &tr, efd);
http_client_close(rtsp);
rtsp = NULL;
tr = NULL;
}

done:
Expand All @@ -1917,7 +1917,7 @@ satip_frontend_input_thread ( void *aux )
goto new_tune;

pthread_mutex_lock(&lfe->sf_dvr_lock);
satip_frontend_request_cleanup(lfe, tr);
satip_frontend_request_cleanup(lfe, &tr);
pthread_mutex_unlock(&lfe->sf_dvr_lock);

if (rtsp)
Expand Down

0 comments on commit 1c0252c

Please sign in to comment.