From: Adam Sutton Date: Fri, 21 Dec 2012 21:50:05 +0000 (+0000) Subject: timeshift: fix use after free() bug. X-Git-Tag: v3.5~144 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=551e5ff8f940cbb196c1921a7a97442f24186a5e;p=thirdparty%2Ftvheadend.git timeshift: fix use after free() bug. --- diff --git a/src/timeshift.c b/src/timeshift.c index ebbb0c647..116575135 100644 --- a/src/timeshift.c +++ b/src/timeshift.c @@ -56,6 +56,7 @@ void timeshift_term ( void ) static void timeshift_input ( void *opaque, streaming_message_t *sm ) { + int exit = 0; timeshift_t *ts = opaque; pthread_mutex_lock(&ts->state_mutex); @@ -81,6 +82,11 @@ static void timeshift_input streaming_target_deliver2(ts->output, streaming_msg_clone(sm)); } + /* Check for exit */ + if (sm->sm_type == SMT_EXIT || + (sm->sm_type == SMT_STOP && sm->sm_code == 0)) + exit = 1; + /* Buffer to disk */ if (ts->state >= TS_LIVE) { sm->sm_time = getmonoclock(); @@ -89,8 +95,7 @@ static void timeshift_input streaming_msg_free(sm); /* Exit/Stop */ - if (sm->sm_type == SMT_EXIT || - (sm->sm_type == SMT_STOP && sm->sm_code == 0)) { + if (exit) { timeshift_write_exit(ts->rd_pipe.wr); ts->state = TS_EXIT; }