editing-services: 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=753864
This commit is contained in:
Vineeth TM 2015-08-20 17:16:50 +09:00 committed by Thibault Saunier
parent a854658404
commit fd29e28c71
8 changed files with 15 additions and 2 deletions

View file

@ -51,6 +51,8 @@ main (int argc, gchar ** 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);
}

View file

@ -149,6 +149,8 @@ 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);
}

View file

@ -57,6 +57,8 @@ main (int argc, gchar ** 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);
}

View file

@ -81,8 +81,10 @@ main (int argc, gchar ** argv)
if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
g_printerr ("Error initializing: %s\n", err->message);
g_option_context_free (ctx);
g_clear_error (&err);
return -1;
}
g_option_context_free (ctx);
if (argc < 3) {
g_print ("Usage: %s <output uri> <list of audio files>\n", argv[0]);

View file

@ -112,6 +112,8 @@ 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);
}

View file

@ -152,6 +152,7 @@ main (int argc, gchar ** 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);
}

View file

@ -173,6 +173,8 @@ 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);
}

View file

@ -288,7 +288,7 @@ bus_message_cb (GstBus * bus, GstMessage * message, GESLauncher * self)
g_printerr ("ERROR from element %s: %s\n", GST_OBJECT_NAME (message->src),
err->message);
g_printerr ("Debugging info: %s\n", (dbg_info) ? dbg_info : "none");
g_error_free (err);
g_clear_error (&err);
g_free (dbg_info);
self->priv->seenerrors = TRUE;
g_application_quit (G_APPLICATION (self));
@ -733,7 +733,7 @@ _local_command_line (GApplication * application, gchar ** arguments[],
if (!g_application_register (application, NULL, &error)) {
*exit_status = 1;
g_error_free (error);
g_clear_error (&error);
return FALSE;
}