Commit 8fe4cd20 authored by Laurent Aimar's avatar Laurent Aimar

Fixed a few memleaks in AVI demuxer.

parent e331532c
...@@ -135,9 +135,6 @@ typedef struct ...@@ -135,9 +135,6 @@ typedef struct
unsigned int i_idxposc; /* numero of chunk */ unsigned int i_idxposc; /* numero of chunk */
unsigned int i_idxposb; /* byte in the current chunk */ unsigned int i_idxposb; /* byte in the current chunk */
/* extra information given to the decoder */
void *p_extra;
/* For VBR audio only */ /* For VBR audio only */
unsigned int i_blockno; unsigned int i_blockno;
unsigned int i_blocksize; unsigned int i_blocksize;
...@@ -437,7 +434,7 @@ static int Open( vlc_object_t * p_this ) ...@@ -437,7 +434,7 @@ static int Open( vlc_object_t * p_this )
fmt.i_extra = __MIN( p_auds->p_wf->cbSize, fmt.i_extra = __MIN( p_auds->p_wf->cbSize,
p_auds->i_chunk_size - sizeof(WAVEFORMATEX) ); 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; if( !fmt.p_extra ) goto error;
memcpy( fmt.p_extra, &p_auds->p_wf[1], fmt.i_extra ); memcpy( fmt.p_extra, &p_auds->p_wf[1], fmt.i_extra );
...@@ -493,7 +490,7 @@ static int Open( vlc_object_t * p_this ) ...@@ -493,7 +490,7 @@ static int Open( vlc_object_t * p_this )
uint8_t *p_out = malloc( i_headers_size ); uint8_t *p_out = malloc( i_headers_size );
if( !p_out ) goto error; if( !p_out ) goto error;
free( fmt.p_extra ); free( fmt.p_extra );
fmt.p_extra = tk->p_extra = p_out; fmt.p_extra = p_out;
fmt.i_extra = i_headers_size; fmt.i_extra = i_headers_size;
#define copy_packet( len ) \ #define copy_packet( len ) \
*p_out++ = len >> 8; \ *p_out++ = len >> 8; \
...@@ -653,6 +650,7 @@ static int Open( vlc_object_t * p_this ) ...@@ -653,6 +650,7 @@ static int Open( vlc_object_t * p_this )
if( tk->p_out_muxed == NULL ) if( tk->p_out_muxed == NULL )
tk->p_es = es_out_Add( p_demux->out, &fmt ); tk->p_es = es_out_Add( p_demux->out, &fmt );
TAB_APPEND( p_sys->i_track, p_sys->track, tk ); TAB_APPEND( p_sys->i_track, p_sys->track, tk );
es_format_Clean( &fmt );
} }
if( p_sys->i_track <= 0 ) if( p_sys->i_track <= 0 )
...@@ -808,7 +806,6 @@ static void Close ( vlc_object_t * p_this ) ...@@ -808,7 +806,6 @@ static void Close ( vlc_object_t * p_this )
if( p_sys->track[i]->p_out_muxed ) if( p_sys->track[i]->p_out_muxed )
stream_Delete( 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_index );
free( p_sys->track[i]->p_extra );
free( p_sys->track[i] ); free( p_sys->track[i] );
} }
} }
...@@ -2321,6 +2318,7 @@ static void AVI_IndexLoad_indx( demux_t *p_demux ) ...@@ -2321,6 +2318,7 @@ static void AVI_IndexLoad_indx( demux_t *p_demux )
break; break;
} }
__Parse_indx( p_demux, i_stream, &ck_sub.indx ); __Parse_indx( p_demux, i_stream, &ck_sub.indx );
AVI_ChunkFree( p_demux->s, &ck_sub );
} }
} }
else else
...@@ -2570,6 +2568,7 @@ static void AVI_ExtractSubtitle( demux_t *p_demux, ...@@ -2570,6 +2568,7 @@ static void AVI_ExtractSubtitle( demux_t *p_demux,
p, i_payload ); p, i_payload );
if( p_attachment ) if( p_attachment )
TAB_APPEND( p_sys->i_attachment, p_sys->attachment, p_attachment ); TAB_APPEND( p_sys->i_attachment, p_sys->attachment, p_attachment );
free( psz_name );
free( psz_description ); free( psz_description );
exit: exit:
...@@ -2580,6 +2579,9 @@ exit: ...@@ -2580,6 +2579,9 @@ exit:
msg_Dbg( p_demux, "Loaded an embed subtitle" ); msg_Dbg( p_demux, "Loaded an embed subtitle" );
else else
msg_Warn( p_demux, "Failed to load an embed subtitle" ); msg_Warn( p_demux, "Failed to load an embed subtitle" );
if( p_indx == &ck.indx )
AVI_ChunkFree( p_demux->s, &ck );
} }
/***************************************************************************** /*****************************************************************************
* Stream management * Stream management
......
...@@ -40,9 +40,6 @@ static vlc_fourcc_t GetFOURCC( const uint8_t *p_buff ) ...@@ -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] ); 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 * Basics functions to manipulates chunks
......
...@@ -216,6 +216,7 @@ typedef union avi_chunk_u ...@@ -216,6 +216,7 @@ typedef union avi_chunk_u
int _AVI_ChunkRead( stream_t *, int _AVI_ChunkRead( stream_t *,
avi_chunk_t *p_chk, avi_chunk_t *p_chk,
avi_chunk_t *p_father ); avi_chunk_t *p_father );
void _AVI_ChunkFree( stream_t *, avi_chunk_t * );
int _AVI_ChunkCount( avi_chunk_t *, vlc_fourcc_t ); int _AVI_ChunkCount( avi_chunk_t *, vlc_fourcc_t );
void *_AVI_ChunkFind ( avi_chunk_t *, vlc_fourcc_t, int ); void *_AVI_ChunkFind ( avi_chunk_t *, vlc_fourcc_t, int );
...@@ -229,6 +230,8 @@ void AVI_ChunkFreeRoot( stream_t *, avi_chunk_t *p_chk ); ...@@ -229,6 +230,8 @@ void AVI_ChunkFreeRoot( stream_t *, avi_chunk_t *p_chk );
_AVI_ChunkCount( (avi_chunk_t*)p_chk, i_fourcc ) _AVI_ChunkCount( (avi_chunk_t*)p_chk, i_fourcc )
#define AVI_ChunkFind( p_chk, i_fourcc, i_number ) \ #define AVI_ChunkFind( p_chk, i_fourcc, i_number ) \
_AVI_ChunkFind( (avi_chunk_t*)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 *** */ /* *** avi stuff *** */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment