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=753852
if (!g_markup_parse_context_parse (ctx, rdf, -1, &err)) {
g_error ("Error parsing file %s: %s\n", fn, err->message);
+ g_clear_error (&err);
}
licenses = g_list_append (licenses, license);
if (dir == NULL)
g_error ("Failed to g_dir_open('%s'): %s", licenses_dir, err->message);
+ g_clear_error (&err);
while ((name = g_dir_read_name (dir))) {
gchar *fn, *rdf;
g_free (rdf);
} else {
g_printerr ("Could not read file '%s': %s\n", fn, err->message);
- g_error_free (err);
+ g_clear_error (&err);
err = NULL;
}
g_free (fn);
g_option_context_add_main_entries (ctx, options, NULL);
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);
exit (1);
}
g_option_context_free (ctx);
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);
}
/* save the pixbuf */
gdk_pixbuf_save (pixbuf, "snapshot.png", "png", &error, NULL);
gst_buffer_unmap (buffer, &map);
+ g_clear_error (&error);
done:
gst_sample_unref (sample);
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);
make_parselaunch_pipeline (const gchar * description)
{
GstElement *pipeline;
- GError *error = NULL;
- pipeline = gst_parse_launch (description, &error);
+ pipeline = gst_parse_launch (description, NULL);
seekable_elements = g_list_prepend (seekable_elements, pipeline);
/* save the pixbuf */
gdk_pixbuf_save (pixbuf, "snapshot.png", "png", &error, NULL);
gst_buffer_unmap (buffer, &map);
-
- /* save the pixbuf */
- gdk_pixbuf_save (pixbuf, "snapshot.png", "png", &error, NULL);
+ g_clear_error (&error);
done:
gst_buffer_unref (buffer);
&bytes_read, &err);
if (err) {
g_print ("error reading from joystick: %s", err->message);
- g_error_free (err);
+ g_clear_error (&err);
return FALSE;
} else if (bytes_read != sizeof (struct js_event)) {
g_print ("error reading joystick, read %u bytes of %u\n",
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 (!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);
}
gst_message_parse_error (msg, &gerror, &debug);
gst_object_default_error (GST_MESSAGE_SRC (msg), gerror, debug);
- g_error_free (gerror);
+ g_clear_error (&gerror);
g_free (debug);
break;
}
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", GST_STR_NULL (err->message));
+ g_option_context_free (ctx);
+ g_clear_error (&err);
exit (1);
}
g_option_context_free (ctx);
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;
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);
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", GST_STR_NULL (err->message));
+ g_option_context_free (ctx);
+ g_clear_error (&err);
return 1;
}
g_option_context_free (ctx);
if (err) {
g_warning ("Couldn't convert filename to URI: %s\n", err->message);
- g_error_free (err);
+ g_clear_error (&err);
return;
}
} else {
g_print ("Analyzing %s\n", uri);
info = gst_discoverer_discover_uri (dc, uri, &err);
print_info (info, err);
- if (err)
- g_error_free (err);
- gst_discoverer_info_unref (info);
+ g_clear_error (&err);
+ if (info)
+ gst_discoverer_info_unref (info);
} else {
gst_discoverer_discover_uri_async (dc, uri);
}
g_printerr ("WARNING %s\n", err->message);
if (dbg != NULL)
g_printerr ("WARNING debug information: %s\n", dbg);
- g_error_free (err);
+ g_clear_error (&err);
g_free (dbg);
break;
}
g_printerr ("ERROR %s for %s\n", err->message, play->uris[play->cur_idx]);
if (dbg != NULL)
g_printerr ("ERROR debug information: %s\n", dbg);
- g_error_free (err);
+ g_clear_error (&err);
g_free (dbg);
/* flush any other error messages from the bus and clean up */
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", GST_STR_NULL (err->message));
+ g_option_context_free (ctx);
+ g_clear_error (&err);
return 1;
}
g_option_context_free (ctx);