Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
tsfix (matroska, htsp): fix memory leaks (refcounting)
  • Loading branch information
perexg committed Sep 17, 2014
1 parent 6df75e8 commit b3586c2
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/plumbing/tsfix.c
Expand Up @@ -237,6 +237,9 @@ recover_pts(tsfix_t *tf, tfstream_t *tfs, th_pkt_t *pkt)
while((pr = TAILQ_FIRST(&tf->tf_ptsq)) != NULL) {

pkt = pr->pr_pkt;
TAILQ_REMOVE(&tf->tf_ptsq, pr, pr_link);
free(pr);

tfs = tfs_find(tf, pkt);

switch(tfs->tfs_type) {
Expand All @@ -258,8 +261,10 @@ recover_pts(tsfix_t *tf, tfstream_t *tfs, th_pkt_t *pkt)
try to find it */
srch = TAILQ_NEXT(pr, pr_link);
while(1) {
if(srch == NULL)
if(srch == NULL) {
pkt_ref_dec(pkt);
return; /* not arrived yet, wait */
}
if(tfs_find(tf, srch->pr_pkt) == tfs &&
srch->pr_pkt->pkt_frametype <= PKT_P_FRAME) {
pkt->pkt_pts = srch->pr_pkt->pkt_dts;
Expand All @@ -278,9 +283,7 @@ recover_pts(tsfix_t *tf, tfstream_t *tfs, th_pkt_t *pkt)
break;
}

TAILQ_REMOVE(&tf->tf_ptsq, pr, pr_link);
normalize_ts(tf, tfs, pkt);
free(pr);
}
}

Expand Down Expand Up @@ -360,15 +363,19 @@ tsfix_input(void *opaque, streaming_message_t *sm)

switch(sm->sm_type) {
case SMT_PACKET:
if (tf->tf_wait_for_video)
if (tf->tf_wait_for_video) {
streaming_msg_free(sm);
return;
}
tsfix_input_packet(tf, sm);
return;

case SMT_START:
tsfix_start(tf, sm->sm_data);
if (tf->tf_wait_for_video)
if (tf->tf_wait_for_video) {
streaming_msg_free(sm);
return;
}
break;

case SMT_STOP:
Expand Down

0 comments on commit b3586c2

Please sign in to comment.