Commit 76233614 authored by Filip Roséen's avatar Filip Roséen Committed by Thomas Guillem

mkv: replace manual memory management of mkv_track_t::psz_codec

The previous implementation caused leakage of the data-member in
question due to missing clean-up. The manual memory management is now
replaced by std::string.
Signed-off-by: Thomas Guillem's avatarThomas Guillem <thomas@gllm.fr>
parent 98086c47
......@@ -909,7 +909,7 @@ void matroska_segment_c::ComputeTrackPriority()
tracks_map_t::key_type track_id = it->first;
tracks_map_t::mapped_type& track = it->second;
if( unlikely( track.fmt.i_cat == UNKNOWN_ES || !track.psz_codec ) )
if( unlikely( track.fmt.i_cat == UNKNOWN_ES || track.codec.empty() ) )
{
msg_Warn( &sys.demuxer, "invalid track[%d]", static_cast<int>( track_id ) );
track.p_es = NULL;
......@@ -1076,7 +1076,7 @@ bool matroska_segment_c::ESCreate()
tracks_map_t::key_type track_id = it->first;
tracks_map_t::mapped_type& track = it->second;
if( unlikely( track.fmt.i_cat == UNKNOWN_ES || !track.psz_codec ) )
if( unlikely( track.fmt.i_cat == UNKNOWN_ES || track.codec.empty() ) )
{
msg_Warn( &sys.demuxer, "invalid track[%d]", static_cast<int>( track_id ) );
track.p_es = NULL;
......
......@@ -215,7 +215,7 @@ void matroska_segment_c::ParseTrackEntry( KaxTrackEntry *m )
track.i_extra_data = 0;
track.p_extra_data = NULL;
track.psz_codec = NULL;
track.codec = "";
track.b_dts_only = false;
track.b_pts_only = false;
......@@ -384,7 +384,7 @@ void matroska_segment_c::ParseTrackEntry( KaxTrackEntry *m )
}
E_CASE( KaxCodecID, codecid )
{
vars.tk->psz_codec = strdup( std::string( codecid ).c_str() );
vars.tk->codec = std::string( codecid );
debug( vars, "Track CodecId=%s", std::string( codecid ).c_str() ) ;
}
E_CASE( KaxCodecPrivate, cpriv )
......@@ -1245,7 +1245,7 @@ void matroska_segment_c::ParseCluster( KaxCluster *cluster, bool b_update_start_
int32_t matroska_segment_c::TrackInit( mkv_track_t * p_tk )
{
if( p_tk->psz_codec == NULL )
if( p_tk->codec.empty() )
{
msg_Err( &sys.demuxer, "Empty codec id" );
p_tk->fmt.i_codec = VLC_FOURCC( 'u', 'n', 'd', 'f' );
......@@ -1819,14 +1819,14 @@ int32_t matroska_segment_c::TrackInit( mkv_track_t * p_tk )
};
try {
TrackCodecHandlers::Dispatcher().send( p_tk->psz_codec,
TrackCodecHandlers::Dispatcher().send( p_tk->codec.c_str(),
TrackCodecHandlers::Payload( captures )
);
}
catch (std::exception const& e)
{
msg_Err( &sys.demuxer, "Error when trying to initiate track (codec: %s): %s",
p_tk->psz_codec, e.what () );
p_tk->codec.c_str(), e.what () );
}
return 0;
......
......@@ -193,7 +193,7 @@ class mkv_track_t
unsigned int i_extra_data;
uint8_t *p_extra_data;
char *psz_codec;
std::string codec;
bool b_dts_only;
bool b_pts_only;
......
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