Commit 290f8be1 authored by Vineeth TM's avatar Vineeth TM Committed by Sebastian Dröge

gstreamer: good: tests: 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

https://bugzilla.gnome.org/show_bug.cgi?id=753853
parent b814d7ed
......@@ -180,8 +180,11 @@ main (int argc, char *argv[])
if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
g_print ("Error initializing: %s\n", err->message);
g_option_context_free (ctx);
g_clear_error (&err);
exit (1);
}
g_option_context_free (ctx);
if (argc < 2) {
g_print ("Usage: %s <uri to play>\n", argv[0]);
......
......@@ -55,7 +55,7 @@ check_bus (GstClockTime max_wait_time)
gst_message_parse_error (msg, &err, &debug);
GST_ERROR ("ERROR: %s [%s]", err->message, debug);
g_print ("\n===========> ERROR: %s\n%s\n\n", err->message, debug);
g_error_free (err);
g_clear_error (&err);
g_free (debug);
}
......@@ -186,8 +186,11 @@ main (int argc, char **argv)
if (!g_option_context_parse (ctx, &argc, &argv, &opt_err)) {
g_error ("Error parsing command line options: %s", opt_err->message);
g_option_context_free (ctx);
g_clear_error (&opt_err);
return -1;
}
g_option_context_free (ctx);
GST_DEBUG_CATEGORY_INIT (equalizer_test_debug, "equalizertest", 0, "eqtest");
......
......@@ -151,7 +151,7 @@ bus_cb (GstBus * bus, GstMessage * msg, gpointer user_data)
gst_message_parse_error (msg, &err, &dbg);
gst_object_default_error (msg->src, err, dbg);
g_error_free (err);
g_clear_error (&err);
g_free (dbg);
g_main_loop_quit (loop);
break;
......@@ -218,6 +218,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", err->message);
g_option_context_free (ctx);
g_clear_error (&err);
return 1;
}
g_option_context_free (ctx);
......
......@@ -175,7 +175,7 @@ bus_message_cb (GstBus * bus, GstMessage * msg, AppInfo * info)
gst_message_parse_error (msg, &err, &dbg);
g_error ("Error: %s\n%s\n", err->message, (dbg) ? dbg : "");
g_error_free (err);
g_clear_error (&err);
g_free (dbg);
break;
}
......@@ -345,6 +345,8 @@ main (int argc, char **argv)
if (!g_option_context_parse (ctx, &argc, &argv, &opt_err)) {
g_error ("Error parsing command line options: %s", opt_err->message);
g_option_context_free (ctx);
g_clear_error (&opt_err);
return -1;
}
......
......@@ -115,6 +115,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", err->message);
g_option_context_free (ctx);
g_clear_error (&err);
exit (1);
}
g_option_context_free (ctx);
......
......@@ -53,7 +53,7 @@ check_bus_for_errors (GstBus * bus, GstClockTime max_wait_time)
gst_message_parse_error (msg, &err, &debug);
GST_ERROR ("ERROR: %s [%s]", err->message, debug);
g_print ("\n===========> ERROR: %s\n%s\n\n", err->message, debug);
g_error_free (err);
g_clear_error (&err);
g_free (debug);
gst_message_unref (msg);
}
......@@ -201,8 +201,11 @@ main (int argc, char **argv)
if (!g_option_context_parse (ctx, &argc, &argv, &opt_err)) {
g_error ("Error parsing command line options: %s", opt_err->message);
g_option_context_free (ctx);
g_clear_error (&opt_err);
return -1;
}
g_option_context_free (ctx);
GST_DEBUG_CATEGORY_INIT (videocrop_test_debug, "videocroptest", 0, "vctest");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment