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
This commit is contained in:
Vineeth TM 2015-08-20 16:03:29 +09:00 committed by Tim-Philipp Müller
parent 16ee1636dc
commit def421acf6
2 changed files with 5 additions and 1 deletions

View file

@ -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);

View file

@ -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);