mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 19:51:11 +00:00
gstreamer: base: 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=753852
This commit is contained in:
parent
0c0f803488
commit
8e5f7f27f5
10 changed files with 33 additions and 15 deletions
|
@ -415,6 +415,7 @@ parse_license_rdf (const gchar * fn, const gchar * rdf)
|
|||
|
||||
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);
|
||||
|
@ -433,6 +434,7 @@ read_licenses (const gchar * licenses_dir)
|
|||
|
||||
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;
|
||||
|
@ -443,7 +445,7 @@ read_licenses (const gchar * licenses_dir)
|
|||
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);
|
||||
|
@ -722,6 +724,8 @@ main (int argc, char **argv)
|
|||
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);
|
||||
|
|
|
@ -399,6 +399,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);
|
||||
}
|
||||
|
||||
|
|
|
@ -1466,6 +1466,7 @@ shot_cb (GtkButton * button, PlaybackApp * app)
|
|||
/* 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);
|
||||
|
@ -3414,6 +3415,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);
|
||||
}
|
||||
g_option_context_free (ctx);
|
||||
|
|
|
@ -961,9 +961,8 @@ static GstElement *
|
|||
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);
|
||||
|
||||
|
@ -2057,9 +2056,7 @@ shot_cb (GtkButton * button, gpointer data)
|
|||
/* 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);
|
||||
|
@ -2624,7 +2621,7 @@ read_joystick (GIOChannel * source, GIOCondition condition, gpointer user_data)
|
|||
&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",
|
||||
|
@ -2678,6 +2675,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);
|
||||
}
|
||||
g_option_context_free (ctx);
|
||||
|
|
|
@ -456,6 +456,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);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ play_file (const gint delay, const gchar * uri)
|
|||
|
||||
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;
|
||||
}
|
||||
|
@ -103,6 +103,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", GST_STR_NULL (err->message));
|
||||
g_option_context_free (ctx);
|
||||
g_clear_error (&err);
|
||||
exit (1);
|
||||
}
|
||||
g_option_context_free (ctx);
|
||||
|
|
|
@ -128,7 +128,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;
|
||||
|
@ -158,6 +158,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);
|
||||
|
|
|
@ -166,6 +166,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", GST_STR_NULL (err->message));
|
||||
g_option_context_free (ctx);
|
||||
g_clear_error (&err);
|
||||
return 1;
|
||||
}
|
||||
g_option_context_free (ctx);
|
||||
|
|
|
@ -487,7 +487,7 @@ process_file (GstDiscoverer * dc, const gchar * filename)
|
|||
|
||||
if (err) {
|
||||
g_warning ("Couldn't convert filename to URI: %s\n", err->message);
|
||||
g_error_free (err);
|
||||
g_clear_error (&err);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
@ -498,9 +498,9 @@ process_file (GstDiscoverer * dc, const gchar * filename)
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -352,7 +352,7 @@ play_bus_msg (GstBus * bus, GstMessage * msg, gpointer user_data)
|
|||
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;
|
||||
}
|
||||
|
@ -368,7 +368,7 @@ play_bus_msg (GstBus * bus, GstMessage * msg, gpointer user_data)
|
|||
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 */
|
||||
|
@ -1139,6 +1139,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", GST_STR_NULL (err->message));
|
||||
g_option_context_free (ctx);
|
||||
g_clear_error (&err);
|
||||
return 1;
|
||||
}
|
||||
g_option_context_free (ctx);
|
||||
|
|
Loading…
Reference in a new issue