rtsp-server: Fix memory leaks when context parse fails
authorVineeth TM <vineeth.tm@samsung.com>
Thu, 20 Aug 2015 08:01:24 +0000 (17:01 +0900)
committerTim-Philipp Müller <tim@centricular.com>
Sat, 26 Sep 2015 08:35:17 +0000 (09:35 +0100)
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=753863

examples/test-launch.c
examples/test-mp4.c
examples/test-ogg.c
examples/test-record.c
examples/test-uri.c

index 24e1271..03bcd41 100644 (file)
@@ -47,6 +47,8 @@ main (int argc, char *argv[])
   g_option_context_add_group (optctx, gst_init_get_option_group ());
   if (!g_option_context_parse (optctx, &argc, &argv, &error)) {
     g_printerr ("Error parsing options: %s\n", error->message);
+    g_option_context_free (optctx);
+    g_clear_error (&error);
     return -1;
   }
   g_option_context_free (optctx);
index 9bcaab4..34b8906 100644 (file)
@@ -102,6 +102,8 @@ main (int argc, char *argv[])
   g_option_context_add_group (optctx, gst_init_get_option_group ());
   if (!g_option_context_parse (optctx, &argc, &argv, &error)) {
     g_printerr ("Error parsing options: %s\n", error->message);
+    g_option_context_free (optctx);
+    g_clear_error (&error);
     return -1;
   }
 
index c22e638..dc052b4 100644 (file)
@@ -47,6 +47,8 @@ main (int argc, char *argv[])
   g_option_context_add_group (optctx, gst_init_get_option_group ());
   if (!g_option_context_parse (optctx, &argc, &argv, &error)) {
     g_printerr ("Error parsing options: %s\n", error->message);
+    g_option_context_free (optctx);
+    g_clear_error (&error);
     return -1;
   }
   g_option_context_free (optctx);
index 1c37503..edd66ad 100644 (file)
@@ -49,6 +49,8 @@ main (int argc, char *argv[])
   g_option_context_add_group (optctx, gst_init_get_option_group ());
   if (!g_option_context_parse (optctx, &argc, &argv, &error)) {
     g_printerr ("Error parsing options: %s\n", error->message);
+    g_option_context_free (optctx);
+    g_clear_error (&error);
     return -1;
   }
 
index 8a9c56c..784bf9a 100644 (file)
@@ -76,6 +76,8 @@ main (int argc, gchar * argv[])
   g_option_context_add_group (optctx, gst_init_get_option_group ());
   if (!g_option_context_parse (optctx, &argc, &argv, &error)) {
     g_printerr ("Error parsing options: %s\n", error->message);
+    g_option_context_free (optctx);
+    g_clear_error (&error);
     return -1;
   }
   g_option_context_free (optctx);