[vlc-devel] commit: Fixed a few memleaks in AVI demuxer. (Laurent Aimar )
git version control
git at videolan.org
Sat Jan 23 21:38:12 CET 2010
vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Sat Jan 23 21:24:30 2010 +0100| [8fe4cd208a50a8a7b2abad17a1eff83e1675fd1f] | committer: Laurent Aimar
Fixed a few memleaks in AVI demuxer.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8fe4cd208a50a8a7b2abad17a1eff83e1675fd1f
---
modules/demux/avi/avi.c | 14 ++++++++------
modules/demux/avi/libavi.c | 3 ---
modules/demux/avi/libavi.h | 3 +++
3 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/modules/demux/avi/avi.c b/modules/demux/avi/avi.c
index 0170e5e..98f0b53 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 ffbb3f9..7da5cb3 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 ff88575..92c4147 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 *** */
More information about the vlc-devel
mailing list