diff options
author | Vineeth TM <vineeth.tm@samsung.com> | 2015-08-20 15:59:15 +0900 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2015-10-02 17:26:27 +0300 |
commit | 8e5f7f27f56e567ab31bb3986f4963fc30c39443 (patch) | |
tree | 7dee5ae605d5a6613582074a71fa2cc4657e74a5 /tools | |
parent | 0c0f80348801cea5f190e6b2024f4c0da5381efd (diff) |
gstreamer: base: Fix memory leaks when context parse fails.
When g_option_context_parse fails, context and error variables are not getting free'd
which results in memory leaks. Free'ing the same.
And replacing g_error_free with g_clear_error, which checks if the error being passed
is not NULL and sets the variable to NULL on free'ing.
https://bugzilla.gnome.org/show_bug.cgi?id=753852
Diffstat (limited to 'tools')
-rw-r--r-- | tools/gst-device-monitor.c | 2 | ||||
-rw-r--r-- | tools/gst-discoverer.c | 8 | ||||
-rw-r--r-- | tools/gst-play.c | 6 |
3 files changed, 10 insertions, 6 deletions
diff --git a/tools/gst-device-monitor.c b/tools/gst-device-monitor.c index c4a1d5ea05..e9c2ed9189 100644 --- a/tools/gst-device-monitor.c +++ b/tools/gst-device-monitor.c @@ -166,6 +166,8 @@ main (int argc, char **argv) g_option_context_add_group (ctx, gst_init_get_option_group ()); if (!g_option_context_parse (ctx, &argc, &argv, &err)) { g_print ("Error initializing: %s\n", GST_STR_NULL (err->message)); + g_option_context_free (ctx); + g_clear_error (&err); return 1; } g_option_context_free (ctx); diff --git a/tools/gst-discoverer.c b/tools/gst-discoverer.c index 16468aeee4..37bb9859d6 100644 --- a/tools/gst-discoverer.c +++ b/tools/gst-discoverer.c @@ -487,7 +487,7 @@ process_file (GstDiscoverer * dc, const gchar * filename) if (err) { g_warning ("Couldn't convert filename to URI: %s\n", err->message); - g_error_free (err); + g_clear_error (&err); return; } } else { @@ -498,9 +498,9 @@ 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); + g_clear_error (&err); + if (info) + gst_discoverer_info_unref (info); } else { gst_discoverer_discover_uri_async (dc, uri); } diff --git a/tools/gst-play.c b/tools/gst-play.c index 15c9aa26d9..40361c0ade 100644 --- a/tools/gst-play.c +++ b/tools/gst-play.c @@ -352,7 +352,7 @@ play_bus_msg (GstBus * bus, GstMessage * msg, gpointer user_data) g_printerr ("WARNING %s\n", err->message); if (dbg != NULL) g_printerr ("WARNING debug information: %s\n", dbg); - g_error_free (err); + g_clear_error (&err); g_free (dbg); break; } @@ -368,7 +368,7 @@ play_bus_msg (GstBus * bus, GstMessage * msg, gpointer user_data) g_printerr ("ERROR %s for %s\n", err->message, play->uris[play->cur_idx]); if (dbg != NULL) g_printerr ("ERROR debug information: %s\n", dbg); - g_error_free (err); + g_clear_error (&err); g_free (dbg); /* flush any other error messages from the bus and clean up */ @@ -1139,6 +1139,8 @@ main (int argc, char **argv) g_option_context_add_group (ctx, gst_init_get_option_group ()); if (!g_option_context_parse (ctx, &argc, &argv, &err)) { g_print ("Error initializing: %s\n", GST_STR_NULL (err->message)); + g_option_context_free (ctx); + g_clear_error (&err); return 1; } g_option_context_free (ctx); |