From def421acf6c37a03322b51f10f9a826540c848eb Mon Sep 17 00:00:00 2001 From: Vineeth TM Date: Thu, 20 Aug 2015 16:03:29 +0900 Subject: [PATCH] gstreamer: bad: 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=753854 --- tests/examples/gl/gtk/fxtest/fxtest.c | 4 +++- tests/examples/gl/gtk/fxtest/pixbufdrop.c | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/examples/gl/gtk/fxtest/fxtest.c b/tests/examples/gl/gtk/fxtest/fxtest.c index f83f189d76..17860eb62d 100644 --- a/tests/examples/gl/gtk/fxtest/fxtest.c +++ b/tests/examples/gl/gtk/fxtest/fxtest.c @@ -76,7 +76,7 @@ end_stream_cb (GstBus * bus, GstMessage * message, GstElement * pipeline) gst_message_parse_error (message, &err, &debug); g_print ("Error: %s\n", err->message); - g_error_free (err); + g_clear_error (&err); if (debug) { g_print ("Debug details: %s\n", debug); @@ -202,6 +202,8 @@ main (gint argc, gchar * argv[]) g_option_context_add_group (context, gtk_get_option_group (TRUE)); if (!g_option_context_parse (context, &argc, &argv, &error)) { g_print ("Inizialization error: %s\n", GST_STR_NULL (error->message)); + g_option_context_free (context); + g_clear_error (&error); return -1; } g_option_context_free (context); diff --git a/tests/examples/gl/gtk/fxtest/pixbufdrop.c b/tests/examples/gl/gtk/fxtest/pixbufdrop.c index 463add362e..69bf3af343 100644 --- a/tests/examples/gl/gtk/fxtest/pixbufdrop.c +++ b/tests/examples/gl/gtk/fxtest/pixbufdrop.c @@ -206,6 +206,8 @@ main (gint argc, gchar * argv[]) g_option_context_add_group (context, gtk_get_option_group (TRUE)); if (!g_option_context_parse (context, &argc, &argv, &error)) { g_print ("Inizialization error: %s\n", GST_STR_NULL (error->message)); + g_option_context_free (context); + g_clear_error (&error); return -1; } g_option_context_free (context);