From 95be60de15801c8fec702672f9c1437298138e2f Mon Sep 17 00:00:00 2001 From: Havard Graff Date: Tue, 1 Nov 2011 17:57:59 +0100 Subject: [PATCH] Fix various unlikely, but still potential memoryleaks in error code paths https://bugzilla.gnome.org/show_bug.cgi?id=667311 --- gst-libs/gst/pbutils/gstdiscoverer-types.c | 4 +++- gst-libs/gst/tag/tags.c | 1 + gst/audiotestsrc/gstaudiotestsrc.c | 2 ++ gst/encoding/gstsmartencoder.c | 5 +++-- gst/playback/gstplaysink.c | 1 + tools/gst-discoverer.c | 2 ++ 6 files changed, 12 insertions(+), 3 deletions(-) diff --git a/gst-libs/gst/pbutils/gstdiscoverer-types.c b/gst-libs/gst/pbutils/gstdiscoverer-types.c index 0d48a3d..1f658c9 100644 --- a/gst-libs/gst/pbutils/gstdiscoverer-types.c +++ b/gst-libs/gst/pbutils/gstdiscoverer-types.c @@ -372,11 +372,13 @@ GstDiscovererInfo * gst_discoverer_info_copy (GstDiscovererInfo * ptr) { GstDiscovererInfo *ret; - GHashTable *stream_map = g_hash_table_new (g_direct_hash, NULL); + GHashTable *stream_map; GList *tmp; g_return_val_if_fail (ptr != NULL, NULL); + stream_map = g_hash_table_new (g_direct_hash, NULL); + ret = gst_discoverer_info_new (); ret->uri = g_strdup (ptr->uri); diff --git a/gst-libs/gst/tag/tags.c b/gst-libs/gst/tag/tags.c index f89b348..80285ae 100644 --- a/gst-libs/gst/tag/tags.c +++ b/gst-libs/gst/tag/tags.c @@ -501,6 +501,7 @@ gst_tag_freeform_string_to_utf8 (const gchar * data, gint size, /* fallback in case iconv implementation doesn't support windows-1252 * for some reason */ if (err->code == G_CONVERT_ERROR_NO_CONVERSION) { + g_free (utf8); utf8 = g_convert (data, size, "UTF-8", "ISO-8859-1", &bytes_read, NULL, NULL); } diff --git a/gst/audiotestsrc/gstaudiotestsrc.c b/gst/audiotestsrc/gstaudiotestsrc.c index 4428cce..f0808c6 100644 --- a/gst/audiotestsrc/gstaudiotestsrc.c +++ b/gst/audiotestsrc/gstaudiotestsrc.c @@ -1166,6 +1166,8 @@ gst_audio_test_src_create (GstBaseSrc * basesrc, guint64 offset, if (eclass->send_event) eclass->send_event (GST_ELEMENT_CAST (basesrc), gst_event_new_tag (taglist)); + else + gst_tag_list_free (taglist); src->tags_pushed = TRUE; } diff --git a/gst/encoding/gstsmartencoder.c b/gst/encoding/gstsmartencoder.c index 97a5635..6d2e778 100644 --- a/gst/encoding/gstsmartencoder.c +++ b/gst/encoding/gstsmartencoder.c @@ -644,9 +644,10 @@ gst_smart_encoder_find_elements (GstSmartEncoder * smart_encoder) gst_caps_unref (tmpl); - if (gst_caps_is_empty (res)) + if (gst_caps_is_empty (res)) { + gst_caps_unref (res); ret = GST_STATE_CHANGE_FAILURE; - else + } else smart_encoder->available_caps = res; GST_DEBUG_OBJECT (smart_encoder, "Done, available_caps:%" GST_PTR_FORMAT, diff --git a/gst/playback/gstplaysink.c b/gst/playback/gstplaysink.c index 81729e6..57d194f 100644 --- a/gst/playback/gstplaysink.c +++ b/gst/playback/gstplaysink.c @@ -2867,6 +2867,7 @@ gst_play_sink_convert_frame (GstPlaySink * playsink, GstCaps * caps) * on the bus or not. It's not like it's a critical issue regarding * playsink behaviour. */ GST_ERROR ("Error converting frame: %s", err->message); + g_error_free (err); } result = temp; } diff --git a/tools/gst-discoverer.c b/tools/gst-discoverer.c index 5a168d6..c6d6092 100644 --- a/tools/gst-discoverer.c +++ b/tools/gst-discoverer.c @@ -456,6 +456,8 @@ process_file (GstDiscoverer * dc, const gchar * filename) g_print ("Analyzing %s\n", uri); info = gst_discoverer_discover_uri (dc, uri, &err); print_info (info, err); + if (err) + g_error_free (err); gst_discoverer_info_unref (info); if (st) gst_structure_free (st); -- 2.7.4