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
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);
}
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);
}
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);
}
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]);
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);
}
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);
}
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_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));
if (!g_application_register (application, NULL, &error)) {
*exit_status = 1;
- g_error_free (error);
+ g_clear_error (&error);
return FALSE;
}