summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorVineeth TM <vineeth.tm@samsung.com>2015-08-20 16:21:59 +0900
committerSebastian Dröge <sebastian@centricular.com>2015-10-02 17:31:11 +0300
commit215cfcf993389c7950d58d7a37d9bfb0058b7ea6 (patch)
tree9418fb46311fd369a218aea847aff1ddf8522516 /tests
parentd3e9f553024262839c34a6ca178470b36162637c (diff)
gstreamer: 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=753851
Diffstat (limited to 'tests')
-rw-r--r--tests/benchmarks/capsnego.c6
-rw-r--r--tests/examples/ptp/ptp-print-times.c1
2 files changed, 5 insertions, 2 deletions
diff --git a/tests/benchmarks/capsnego.c b/tests/benchmarks/capsnego.c
index e035ddccf..dc60194e3 100644
--- a/tests/benchmarks/capsnego.c
+++ b/tests/benchmarks/capsnego.c
@@ -157,7 +157,7 @@ event_loop (GstElement * bin)
gst_message_parse_warning (msg, &err, &dbg);
GST_WARNING_OBJECT (GST_MESSAGE_SRC (msg), "%s (%s)", err->message,
(dbg ? dbg : "no details"));
- g_error_free (err);
+ g_clear_error (&err);
g_free (dbg);
break;
}
@@ -168,7 +168,7 @@ event_loop (GstElement * bin)
gst_message_parse_error (msg, &err, &dbg);
GST_ERROR_OBJECT (GST_MESSAGE_SRC (msg), "%s (%s)", err->message,
(dbg ? dbg : "no details"));
- g_error_free (err);
+ g_clear_error (&err);
g_free (dbg);
running = FALSE;
break;
@@ -218,6 +218,8 @@ main (gint argc, gchar * 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_clear_error (&err);
+ g_option_context_free (ctx);
return 1;
}
g_option_context_free (ctx);
diff --git a/tests/examples/ptp/ptp-print-times.c b/tests/examples/ptp/ptp-print-times.c
index e6c666fdc..b7de82a96 100644
--- a/tests/examples/ptp/ptp-print-times.c
+++ b/tests/examples/ptp/ptp-print-times.c
@@ -70,6 +70,7 @@ main (gint argc, gchar ** argv)
g_option_context_add_group (opt_ctx, gst_init_get_option_group ());
if (!g_option_context_parse (opt_ctx, &argc, &argv, &err))
g_error ("Error parsing options: %s", err->message);
+ g_clear_error (&err);
g_option_context_free (opt_ctx);
if (!gst_ptp_init (GST_PTP_CLOCK_ID_NONE, NULL))