[vlc-commits] demux: mkv: use libmp4 de/allocators
Francois Cartegnie
git at videolan.org
Wed Aug 3 14:49:38 CEST 2016
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Aug 3 13:59:12 2016 +0200| [21690883f4ce9f9c3c7859e1684461262ee0e984] | committer: Francois Cartegnie
demux: mkv: use libmp4 de/allocators
Avoids memory leaks with stsd sub atoms
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=21690883f4ce9f9c3c7859e1684461262ee0e984
---
modules/demux/mkv/matroska_segment_parse.cpp | 43 ++++++++++++++--------------
1 file changed, 21 insertions(+), 22 deletions(-)
diff --git a/modules/demux/mkv/matroska_segment_parse.cpp b/modules/demux/mkv/matroska_segment_parse.cpp
index 59c7952..52897c0 100644
--- a/modules/demux/mkv/matroska_segment_parse.cpp
+++ b/modules/demux/mkv/matroska_segment_parse.cpp
@@ -1361,32 +1361,31 @@ int32_t matroska_segment_c::TrackInit( mkv_track_t * p_tk )
fill_extra_data( vars.p_tk, 0 );
}
S_CASE("V_QUICKTIME") {
- MP4_Box_t *p_box = (MP4_Box_t*)xmalloc( sizeof( MP4_Box_t ) );
- stream_t *p_mp4_stream = vlc_stream_MemoryNew( VLC_OBJECT(vars.p_demuxer),
- vars.p_tk->p_extra_data,
- vars.p_tk->i_extra_data,
- true );
- if( MP4_PeekBoxHeader( p_mp4_stream, p_box ) &&
- MP4_ReadBox_sample_vide( p_mp4_stream, p_box ) )
+ MP4_Box_t *p_box = MP4_BoxNew(ATOM_root);
+ if( p_box )
{
- vars.p_fmt->i_codec = p_box->i_type;
- uint32_t i_width = p_box->data.p_sample_vide->i_width;
- uint32_t i_height = p_box->data.p_sample_vide->i_height;
- if( i_width && i_height )
+ stream_t *p_mp4_stream = vlc_stream_MemoryNew( VLC_OBJECT(vars.p_demuxer),
+ vars.p_tk->p_extra_data,
+ vars.p_tk->i_extra_data,
+ true );
+ if( MP4_PeekBoxHeader( p_mp4_stream, p_box ) &&
+ MP4_ReadBox_sample_vide( p_mp4_stream, p_box ) )
{
- vars.p_tk->fmt.video.i_width = i_width;
- vars.p_tk->fmt.video.i_height = i_height;
+ vars.p_fmt->i_codec = p_box->i_type;
+ uint32_t i_width = p_box->data.p_sample_vide->i_width;
+ uint32_t i_height = p_box->data.p_sample_vide->i_height;
+ if( i_width && i_height )
+ {
+ vars.p_tk->fmt.video.i_width = i_width;
+ vars.p_tk->fmt.video.i_height = i_height;
+ }
+ vars.p_fmt->i_extra = p_box->data.p_sample_vide->i_qt_image_description;
+ vars.p_fmt->p_extra = xmalloc( vars.p_fmt->i_extra );
+ memcpy( vars.p_fmt->p_extra, p_box->data.p_sample_vide->p_qt_image_description, vars.p_fmt->i_extra );
}
- vars.p_fmt->i_extra = p_box->data.p_sample_vide->i_qt_image_description;
- vars.p_fmt->p_extra = xmalloc( vars.p_fmt->i_extra );
- memcpy( vars.p_fmt->p_extra, p_box->data.p_sample_vide->p_qt_image_description, vars.p_fmt->i_extra );
- MP4_FreeBox_sample_vide( p_box );
- }
- else
- {
- free( p_box );
+ MP4_BoxFree( p_box );
+ vlc_stream_Delete( p_mp4_stream );
}
- vlc_stream_Delete( p_mp4_stream );
}
S_CASE("V_MJPEG") {
vars.p_fmt->i_codec = VLC_CODEC_MJPG;
More information about the vlc-commits
mailing list