From: Laurent Aimar Date: Sat, 23 Jan 2010 20:24:30 +0000 (+0100) Subject: Fixed a few memleaks in AVI demuxer. X-Git-Tag: 1.1.0-ff~992 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=8fe4cd208a50a8a7b2abad17a1eff83e1675fd1f;p=vlc Fixed a few memleaks in AVI demuxer. --- diff --git a/modules/demux/avi/avi.c b/modules/demux/avi/avi.c index 0170e5ef5d..98f0b5302d 100644 --- a/modules/demux/avi/avi.c +++ b/modules/demux/avi/avi.c @@ -135,9 +135,6 @@ typedef struct unsigned int i_idxposc; /* numero of chunk */ unsigned int i_idxposb; /* byte in the current chunk */ - /* extra information given to the decoder */ - void *p_extra; - /* For VBR audio only */ unsigned int i_blockno; unsigned int i_blocksize; @@ -437,7 +434,7 @@ static int Open( vlc_object_t * p_this ) fmt.i_extra = __MIN( p_auds->p_wf->cbSize, p_auds->i_chunk_size - sizeof(WAVEFORMATEX) ); - fmt.p_extra = tk->p_extra = malloc( fmt.i_extra ); + fmt.p_extra = malloc( fmt.i_extra ); if( !fmt.p_extra ) goto error; memcpy( fmt.p_extra, &p_auds->p_wf[1], fmt.i_extra ); @@ -493,7 +490,7 @@ static int Open( vlc_object_t * p_this ) uint8_t *p_out = malloc( i_headers_size ); if( !p_out ) goto error; free( fmt.p_extra ); - fmt.p_extra = tk->p_extra = p_out; + fmt.p_extra = p_out; fmt.i_extra = i_headers_size; #define copy_packet( len ) \ *p_out++ = len >> 8; \ @@ -653,6 +650,7 @@ static int Open( vlc_object_t * p_this ) if( tk->p_out_muxed == NULL ) tk->p_es = es_out_Add( p_demux->out, &fmt ); TAB_APPEND( p_sys->i_track, p_sys->track, tk ); + es_format_Clean( &fmt ); } if( p_sys->i_track <= 0 ) @@ -808,7 +806,6 @@ static void Close ( vlc_object_t * p_this ) if( p_sys->track[i]->p_out_muxed ) stream_Delete( p_sys->track[i]->p_out_muxed ); free( p_sys->track[i]->p_index ); - free( p_sys->track[i]->p_extra ); free( p_sys->track[i] ); } } @@ -2321,6 +2318,7 @@ static void AVI_IndexLoad_indx( demux_t *p_demux ) break; } __Parse_indx( p_demux, i_stream, &ck_sub.indx ); + AVI_ChunkFree( p_demux->s, &ck_sub ); } } else @@ -2570,6 +2568,7 @@ static void AVI_ExtractSubtitle( demux_t *p_demux, p, i_payload ); if( p_attachment ) TAB_APPEND( p_sys->i_attachment, p_sys->attachment, p_attachment ); + free( psz_name ); free( psz_description ); exit: @@ -2580,6 +2579,9 @@ exit: msg_Dbg( p_demux, "Loaded an embed subtitle" ); else msg_Warn( p_demux, "Failed to load an embed subtitle" ); + + if( p_indx == &ck.indx ) + AVI_ChunkFree( p_demux->s, &ck ); } /***************************************************************************** * Stream management diff --git a/modules/demux/avi/libavi.c b/modules/demux/avi/libavi.c index ffbb3f9b16..7da5cb3300 100644 --- a/modules/demux/avi/libavi.c +++ b/modules/demux/avi/libavi.c @@ -40,9 +40,6 @@ static vlc_fourcc_t GetFOURCC( const uint8_t *p_buff ) return VLC_FOURCC( p_buff[0], p_buff[1], p_buff[2], p_buff[3] ); } -#define AVI_ChunkFree( a, b ) _AVI_ChunkFree( (a), (avi_chunk_t*)(b) ) -void _AVI_ChunkFree( stream_t *, avi_chunk_t *p_chk ); - /**************************************************************************** * * Basics functions to manipulates chunks diff --git a/modules/demux/avi/libavi.h b/modules/demux/avi/libavi.h index ff88575372..92c4147cb4 100644 --- a/modules/demux/avi/libavi.h +++ b/modules/demux/avi/libavi.h @@ -216,6 +216,7 @@ typedef union avi_chunk_u int _AVI_ChunkRead( stream_t *, avi_chunk_t *p_chk, avi_chunk_t *p_father ); +void _AVI_ChunkFree( stream_t *, avi_chunk_t * ); int _AVI_ChunkCount( avi_chunk_t *, vlc_fourcc_t ); void *_AVI_ChunkFind ( avi_chunk_t *, vlc_fourcc_t, int ); @@ -229,6 +230,8 @@ void AVI_ChunkFreeRoot( stream_t *, avi_chunk_t *p_chk ); _AVI_ChunkCount( (avi_chunk_t*)p_chk, i_fourcc ) #define AVI_ChunkFind( p_chk, i_fourcc, i_number ) \ _AVI_ChunkFind( (avi_chunk_t*)p_chk, i_fourcc, i_number ) +#define AVI_ChunkFree( a, b ) \ + _AVI_ChunkFree( (a), (avi_chunk_t*)(b) ) /* *** avi stuff *** */