From: Ursula Maplehurst Date: Sun, 29 May 2016 16:21:47 +0000 (+0100) Subject: multifilesink: don't leak memory when no max-files limit is set X-Git-Tag: 1.12.2~251 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a10c1cc060648fd3ac6ab47d241f54eafc756248;p=platform%2Fupstream%2Fgst-plugins-good.git multifilesink: don't leak memory when no max-files limit is set Technically we weren't leaking the memory, just storing it internally and never using it until the element is freed. But we'd still use more and more memory over time, so this is not good over longer periods of time. Only keep track of files if there's actually a limit set, so that we will prune the list from time to time. https://bugzilla.gnome.org/show_bug.cgi?id=766991 --- diff --git a/gst/multifile/gstmultifilesink.c b/gst/multifile/gstmultifilesink.c index 2b83c0b..8a70f50 100644 --- a/gst/multifile/gstmultifilesink.c +++ b/gst/multifile/gstmultifilesink.c @@ -1098,8 +1098,14 @@ gst_multi_file_sink_open_next_file (GstMultiFileSink * multifilesink) } GST_INFO_OBJECT (multifilesink, "opening file %s", filename); - multifilesink->files = g_slist_append (multifilesink->files, filename); - multifilesink->n_files += 1; + + /* Only add file to the list if max_files > 0, otherwise this leaks memory */ + if (multifilesink->max_files) { + multifilesink->files = g_slist_append (multifilesink->files, filename); + multifilesink->n_files += 1; + } else { + g_free (filename); + } multifilesink->cur_file_size = 0; return TRUE;