Commit 61b10177 authored by Steve Lhomme's avatar Steve Lhomme Committed by 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's avatarJean-Baptiste Kempf <jb@videolan.org>
parent a6785624
......@@ -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 ) )
{
......
......@@ -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;
......
......@@ -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
......
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