[vlc-commits] mkv: don't let zlib_decompress_extra() destroy the track it's given
Steve Lhomme
git at videolan.org
Mon Jul 31 15:23:17 CEST 2017
vlc | branch: master | Steve Lhomme <robUx4 at videolabs.io> | Mon Jul 31 15:02:55 2017 +0200| [61b1017795a8e2b2f922bedc7a4129150c8aee6c] | committer: Jean-Baptiste Kempf
mkv: don't let zlib_decompress_extra() destroy the track it's given
It didn't clean the es_format_t that's fully filled.
Also emit an error telling we can't handle the compression.
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=61b1017795a8e2b2f922bedc7a4129150c8aee6c
---
modules/demux/mkv/matroska_segment_parse.cpp | 8 ++++++--
modules/demux/mkv/util.cpp | 28 ++++++++++------------------
modules/demux/mkv/util.hpp | 2 +-
3 files changed, 17 insertions(+), 21 deletions(-)
diff --git a/modules/demux/mkv/matroska_segment_parse.cpp b/modules/demux/mkv/matroska_segment_parse.cpp
index 896d6bd77e..7fa5da49cc 100644
--- a/modules/demux/mkv/matroska_segment_parse.cpp
+++ b/modules/demux/mkv/matroska_segment_parse.cpp
@@ -684,9 +684,13 @@ void matroska_segment_c::ParseTrackEntry( const KaxTrackEntry *m )
if( track.i_compression_type == MATROSKA_COMPRESSION_ZLIB &&
track.i_encoding_scope & MATROSKA_ENCODING_SCOPE_PRIVATE &&
track.i_extra_data && track.p_extra_data &&
- zlib_decompress_extra( &sys.demuxer, &track ) )
- // zlib_decompress_extra will clean the track itself
+ zlib_decompress_extra( &sys.demuxer, track ) )
+ {
+ msg_Err(&sys.demuxer, "Couldn't handle the track %u compression", track.i_number );
+ es_format_Clean( &track.fmt );
+ free(track.p_extra_data);
return;
+ }
#endif
if( TrackInit( &track ) )
{
diff --git a/modules/demux/mkv/util.cpp b/modules/demux/mkv/util.cpp
index 1a4f157e8c..bef5cca6c2 100644
--- a/modules/demux/mkv/util.cpp
+++ b/modules/demux/mkv/util.cpp
@@ -30,7 +30,7 @@
*****************************************************************************/
#ifdef HAVE_ZLIB_H
-int32_t zlib_decompress_extra( demux_t * p_demux, mkv_track_t * tk )
+int32_t zlib_decompress_extra( demux_t * p_demux, mkv_track_t & tk )
{
int result;
z_stream d_stream;
@@ -45,14 +45,12 @@ int32_t zlib_decompress_extra( demux_t * p_demux, mkv_track_t * tk )
if( inflateInit( &d_stream ) != Z_OK )
{
msg_Err( p_demux, "Couldn't initiate inflation ignore track %u",
- tk->i_number );
- free(tk->p_extra_data);
- delete tk;
+ tk.i_number );
return 1;
}
- d_stream.next_in = tk->p_extra_data;
- d_stream.avail_in = tk->i_extra_data;
+ d_stream.next_in = tk.p_extra_data;
+ d_stream.avail_in = tk.i_extra_data;
do
{
n++;
@@ -60,11 +58,9 @@ int32_t zlib_decompress_extra( demux_t * p_demux, mkv_track_t * tk )
if( alloc == NULL )
{
msg_Err( p_demux, "Couldn't allocate buffer to inflate data, ignore track %u",
- tk->i_number );
+ tk.i_number );
free(p_new_extra);
inflateEnd( &d_stream );
- free(tk->p_extra_data);
- delete tk;
return 1;
}
@@ -77,28 +73,24 @@ int32_t zlib_decompress_extra( demux_t * p_demux, mkv_track_t * tk )
msg_Err( p_demux, "Zlib decompression failed. Result: %d", result );
inflateEnd( &d_stream );
free(p_new_extra);
- free(tk->p_extra_data);
- delete tk;
return 1;
}
}
while ( d_stream.avail_out == 0 && d_stream.avail_in != 0 &&
result != Z_STREAM_END );
- free( tk->p_extra_data );
- tk->i_extra_data = d_stream.total_out;
- p_new_extra = static_cast<uint8_t *>( realloc(p_new_extra, tk->i_extra_data) );
+ free( tk.p_extra_data );
+ tk.i_extra_data = d_stream.total_out;
+ p_new_extra = static_cast<uint8_t *>( realloc(p_new_extra, tk.i_extra_data) );
if( !p_new_extra )
{
msg_Err( p_demux, "Couldn't allocate buffer to inflate data, ignore track %u",
- tk->i_number );
+ tk.i_number );
inflateEnd( &d_stream );
- free(p_new_extra);
- delete tk;
return 1;
}
- tk->p_extra_data = p_new_extra;
+ tk.p_extra_data = p_new_extra;
inflateEnd( &d_stream );
return 0;
diff --git a/modules/demux/mkv/util.hpp b/modules/demux/mkv/util.hpp
index 5867d1d39e..7bee3640e1 100644
--- a/modules/demux/mkv/util.hpp
+++ b/modules/demux/mkv/util.hpp
@@ -26,7 +26,7 @@
#include "mkv.hpp"
#ifdef HAVE_ZLIB_H
-int32_t zlib_decompress_extra( demux_t * p_demux, mkv_track_t * tk );
+int32_t zlib_decompress_extra( demux_t * p_demux, mkv_track_t & tk );
block_t *block_zlib_decompress( vlc_object_t *p_this, block_t *p_in_block );
#endif
More information about the vlc-commits
mailing list