avi: Fix potential leak
authorHugo Beauzée-Luyssen <hugo@beauzee.fr>
Thu, 11 Jun 2020 14:14:58 +0000 (16:14 +0200)
committerHugo Beauzée-Luyssen <hugo@beauzee.fr>
Fri, 12 Jun 2020 08:15:15 +0000 (10:15 +0200)
When AVI_IndexLoad gets invoked multiple time on the same file, we end
up overwriting the previous index table.

modules/demux/avi/avi.c

index 38c8cb6..34bd228 100644 (file)
@@ -2549,12 +2549,14 @@ static void AVI_IndexLoad( demux_t *p_demux )
         if( p_idx_indx[i].i_size > p_idx_idx1[i].i_size )
         {
             msg_Dbg( p_demux, "selected ODML index for stream[%u]", i );
         if( p_idx_indx[i].i_size > p_idx_idx1[i].i_size )
         {
             msg_Dbg( p_demux, "selected ODML index for stream[%u]", i );
+            free(p_sys->track[i]->idx.p_entry);
             p_sys->track[i]->idx = p_idx_indx[i];
             avi_index_Clean( &p_idx_idx1[i] );
         }
         else
         {
             msg_Dbg( p_demux, "selected standard index for stream[%u]", i );
             p_sys->track[i]->idx = p_idx_indx[i];
             avi_index_Clean( &p_idx_idx1[i] );
         }
         else
         {
             msg_Dbg( p_demux, "selected standard index for stream[%u]", i );
+            free(p_sys->track[i]->idx.p_entry);
             p_sys->track[i]->idx = p_idx_idx1[i];
             avi_index_Clean( &p_idx_indx[i] );
         }
             p_sys->track[i]->idx = p_idx_idx1[i];
             avi_index_Clean( &p_idx_indx[i] );
         }