[vlc-devel] [PATCH] mkv: fixed memory-leak related to mkv_track_t::fmt
Filip Roséen
filip at atch.se
Thu Sep 1 04:06:18 CEST 2016
If we do not insert the given track into our maps of tracks, we would
previously not invoke es_format_Clean on the given fmt, which of
course would leak dynamically allocated members.
There was also an issue with assigning values to data-members that
would later be overwritten, of course directly causing dynamically
allocated data to be leaked.
---
modules/demux/mkv/matroska_segment_parse.cpp | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/modules/demux/mkv/matroska_segment_parse.cpp b/modules/demux/mkv/matroska_segment_parse.cpp
index 67237f3..dcf201f 100644
--- a/modules/demux/mkv/matroska_segment_parse.cpp
+++ b/modules/demux/mkv/matroska_segment_parse.cpp
@@ -207,9 +207,6 @@ void matroska_segment_c::ParseTrackEntry( KaxTrackEntry *m )
/* Init the track */
mkv_track_t track;
- track.fmt.psz_language = strdup("English");
- track.fmt.psz_description = NULL;
-
track.b_default = true;
track.b_enabled = true;
track.b_forced = false;
@@ -230,6 +227,10 @@ void matroska_segment_c::ParseTrackEntry( KaxTrackEntry *m )
std::memset( &track.fmt, 0, sizeof( track.fmt ) );
es_format_Init( &track.fmt, UNKNOWN_ES, 0 );
+
+ track.fmt.psz_language = strdup("English");
+ track.fmt.psz_description = NULL;
+
track.f_fps = 0;
track.p_es = NULL;
@@ -672,6 +673,7 @@ void matroska_segment_c::ParseTrackEntry( KaxTrackEntry *m )
else
{
msg_Err( &sys.demuxer, "Track Entry %u not supported", track.i_number );
+ es_format_Clean( &track.fmt );
free(track.p_extra_data);
}
}
--
2.9.3
More information about the vlc-devel
mailing list