]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
tsfix (matroska, htsp): fix memory leaks (refcounting)
authorJaroslav Kysela <perex@perex.cz>
Wed, 17 Sep 2014 12:53:58 +0000 (14:53 +0200)
committerJaroslav Kysela <perex@perex.cz>
Wed, 17 Sep 2014 12:54:38 +0000 (14:54 +0200)
src/plumbing/tsfix.c

index 2a8a554b6c7c565481f80c56689d2f2fbc125ed2..09f69c28ff61552b54a59d5ee5ce4f0d8bc32b21 100644 (file)
@@ -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) {
@@ -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;
@@ -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);
   }
 }
 
@@ -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: