From 0e62a0603de8512a85636bd4cd046939672a4c3f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 8 Mar 2017 15:27:32 +0200 Subject: [PATCH] qtmux: Fix some memory leaks related to timecode tracks --- gst/isomp4/atoms.c | 12 ++++++++++++ gst/isomp4/gstqtmux.c | 5 ++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/gst/isomp4/atoms.c b/gst/isomp4/atoms.c index ce5039e..1f98a9a 100644 --- a/gst/isomp4/atoms.c +++ b/gst/isomp4/atoms.c @@ -566,6 +566,14 @@ sample_entry_tmcd_new (void) } static void +sample_entry_tmcd_free (SampleTableEntryTMCD * tmcd) +{ + atom_sample_entry_free (&tmcd->se); + g_free (tmcd->name.name); + g_free (tmcd); +} + +static void sample_entry_mp4v_init (SampleTableEntryMP4V * mp4v, AtomsContext * context) { atom_sample_entry_init (&mp4v->se, FOURCC_mp4v); @@ -674,6 +682,9 @@ atom_stsd_remove_entries (AtomSTSD * stsd) case SUBTITLE: sample_entry_tx3g_free ((SampleTableEntryTX3G *) se); break; + case TIMECODE: + sample_entry_tmcd_free ((SampleTableEntryTMCD *) se); + break; default: /* best possible cleanup */ atom_sample_entry_free (se); @@ -3777,6 +3788,7 @@ atom_trak_add_timecode_entry (AtomTRAK * trak, AtomsContext * context, trak->mdia.hdlr.component_type = FOURCC_mhlr; trak->mdia.hdlr.handler_type = FOURCC_tmcd; + g_free (trak->mdia.hdlr.name); trak->mdia.hdlr.name = g_strdup ("Time Code Media Handler"); trak->mdia.mdhd.time_info.timescale = tc->config.fps_n / tc->config.fps_d; diff --git a/gst/isomp4/gstqtmux.c b/gst/isomp4/gstqtmux.c index d49bc9f..8df0394 100644 --- a/gst/isomp4/gstqtmux.c +++ b/gst/isomp4/gstqtmux.c @@ -518,7 +518,6 @@ gst_qt_mux_pad_reset (GstQTPad * qtpad) qtpad->total_duration = 0; qtpad->total_bytes = 0; qtpad->sparse = FALSE; - qtpad->tc_trak = NULL; qtpad->buf_head = 0; qtpad->buf_tail = 0; @@ -532,6 +531,7 @@ gst_qt_mux_pad_reset (GstQTPad * qtpad) /* reference owned elsewhere */ qtpad->trak = NULL; + qtpad->tc_trak = NULL; if (qtpad->traf) { atom_traf_free (qtpad->traf); @@ -624,6 +624,9 @@ gst_qt_mux_reset (GstQTMux * qtmux, gboolean alloc) qtmux->reserved_duration_remaining = GST_CLOCK_TIME_NONE; qtmux->first_pts = GST_CLOCK_TIME_NONE; qtmux->tc_pos = -1; + if (qtmux->first_tc) + gst_video_time_code_free (qtmux->first_tc); + qtmux->first_tc = NULL; } static void -- 2.7.4