[glib] gio-tool: Do not leak GOptionContext
- From: Ondrej Holy <oholy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] gio-tool: Do not leak GOptionContext
- Date: Mon, 10 Apr 2017 08:18:44 +0000 (UTC)
commit fb7d2184a616553fdc1881fe52ebe2a3c7748280
Author: Ondrej Holy <oholy redhat com>
Date: Mon Dec 19 12:11:13 2016 +0100
gio-tool: Do not leak GOptionContext
GOptionContext is freed only in case of success. Free the context
also in case of failure.
https://bugzilla.gnome.org/show_bug.cgi?id=776169
gio/gio-tool-cat.c | 3 +++
gio/gio-tool-copy.c | 5 +++++
gio/gio-tool-info.c | 3 +++
gio/gio-tool-list.c | 2 ++
gio/gio-tool-mime.c | 3 +++
gio/gio-tool-mkdir.c | 3 +++
gio/gio-tool-monitor.c | 3 +++
gio/gio-tool-mount.c | 2 ++
gio/gio-tool-move.c | 4 ++++
gio/gio-tool-open.c | 3 +++
gio/gio-tool-remove.c | 3 +++
gio/gio-tool-rename.c | 4 ++++
gio/gio-tool-save.c | 4 ++++
gio/gio-tool-set.c | 6 ++++++
gio/gio-tool-trash.c | 2 ++
gio/gio-tool-tree.c | 2 ++
16 files changed, 52 insertions(+), 0 deletions(-)
---
diff --git a/gio/gio-tool-cat.c b/gio/gio-tool-cat.c
index 3dc02d1..d09fbda 100644
--- a/gio/gio-tool-cat.c
+++ b/gio/gio-tool-cat.c
@@ -136,6 +136,7 @@ handle_cat (int argc, char *argv[], gboolean do_help)
if (do_help)
{
show_help (context, NULL);
+ g_option_context_free (context);
return 0;
}
@@ -143,12 +144,14 @@ handle_cat (int argc, char *argv[], gboolean do_help)
{
show_help (context, error->message);
g_error_free (error);
+ g_option_context_free (context);
return 1;
}
if (argc < 2)
{
show_help (context, _("No locations given"));
+ g_option_context_free (context);
return 1;
}
diff --git a/gio/gio-tool-copy.c b/gio/gio-tool-copy.c
index c64fd4e..706827c 100644
--- a/gio/gio-tool-copy.c
+++ b/gio/gio-tool-copy.c
@@ -110,6 +110,7 @@ handle_copy (int argc, char *argv[], gboolean do_help)
if (do_help)
{
show_help (context, NULL);
+ g_option_context_free (context);
return 0;
}
@@ -117,12 +118,14 @@ handle_copy (int argc, char *argv[], gboolean do_help)
{
show_help (context, error->message);
g_error_free (error);
+ g_option_context_free (context);
return 1;
}
if (argc < 3)
{
show_help (context, NULL);
+ g_option_context_free (context);
return 1;
}
@@ -132,6 +135,7 @@ handle_copy (int argc, char *argv[], gboolean do_help)
{
show_help (context, NULL);
g_object_unref (dest);
+ g_option_context_free (context);
return 1;
}
@@ -144,6 +148,7 @@ handle_copy (int argc, char *argv[], gboolean do_help)
show_help (context, message);
g_free (message);
g_object_unref (dest);
+ g_option_context_free (context);
return 1;
}
diff --git a/gio/gio-tool-info.c b/gio/gio-tool-info.c
index 570322d..9cd2ea2 100644
--- a/gio/gio-tool-info.c
+++ b/gio/gio-tool-info.c
@@ -296,6 +296,7 @@ handle_info (int argc, char *argv[], gboolean do_help)
if (do_help)
{
show_help (context, NULL);
+ g_option_context_free (context);
return 0;
}
@@ -303,12 +304,14 @@ handle_info (int argc, char *argv[], gboolean do_help)
{
show_help (context, error->message);
g_error_free (error);
+ g_option_context_free (context);
return 1;
}
if (argc < 2)
{
show_help (context, _("No locations given"));
+ g_option_context_free (context);
return 1;
}
diff --git a/gio/gio-tool-list.c b/gio/gio-tool-list.c
index 528024f..116ed1f 100644
--- a/gio/gio-tool-list.c
+++ b/gio/gio-tool-list.c
@@ -178,6 +178,7 @@ handle_list (int argc, char *argv[], gboolean do_help)
if (do_help)
{
show_help (context, NULL);
+ g_option_context_free (context);
return 0;
}
@@ -185,6 +186,7 @@ handle_list (int argc, char *argv[], gboolean do_help)
{
show_help (context, error->message);
g_error_free (error);
+ g_option_context_free (context);
return 1;
}
diff --git a/gio/gio-tool-mime.c b/gio/gio-tool-mime.c
index ead2f12..8654166 100644
--- a/gio/gio-tool-mime.c
+++ b/gio/gio-tool-mime.c
@@ -83,6 +83,7 @@ handle_mime (int argc, char *argv[], gboolean do_help)
if (do_help)
{
show_help (context, NULL);
+ g_option_context_free (context);
return 0;
}
@@ -90,12 +91,14 @@ handle_mime (int argc, char *argv[], gboolean do_help)
{
show_help (context, error->message);
g_error_free (error);
+ g_option_context_free (context);
return 1;
}
if (argc != 2 && argc != 3)
{
show_help (context, _("Must specify a single mimetype, and maybe a handler"));
+ g_option_context_free (context);
return 1;
}
diff --git a/gio/gio-tool-mkdir.c b/gio/gio-tool-mkdir.c
index 6e955a8..060e568 100644
--- a/gio/gio-tool-mkdir.c
+++ b/gio/gio-tool-mkdir.c
@@ -59,6 +59,7 @@ handle_mkdir (int argc, char *argv[], gboolean do_help)
if (do_help)
{
show_help (context, NULL);
+ g_option_context_free (context);
return 0;
}
@@ -66,12 +67,14 @@ handle_mkdir (int argc, char *argv[], gboolean do_help)
{
show_help (context, error->message);
g_error_free (error);
+ g_option_context_free (context);
return 1;
}
if (argc < 2)
{
show_help (context, _("No locations given"));
+ g_option_context_free (context);
return 1;
}
diff --git a/gio/gio-tool-monitor.c b/gio/gio-tool-monitor.c
index cfdcdbf..c9d878a 100644
--- a/gio/gio-tool-monitor.c
+++ b/gio/gio-tool-monitor.c
@@ -211,6 +211,7 @@ handle_monitor (int argc, gchar *argv[], gboolean do_help)
if (do_help)
{
show_help (context, NULL);
+ g_option_context_free (context);
return 0;
}
@@ -218,12 +219,14 @@ handle_monitor (int argc, gchar *argv[], gboolean do_help)
{
show_help (context, error->message);
g_error_free (error);
+ g_option_context_free (context);
return 1;
}
if (!watch_dirs || !watch_files || !watch_direct || !watch_silent || !watch_default)
{
show_help (context, _("No locations given"));
+ g_option_context_free (context);
return 1;
}
diff --git a/gio/gio-tool-mount.c b/gio/gio-tool-mount.c
index 50ee5cd..e04004a 100644
--- a/gio/gio-tool-mount.c
+++ b/gio/gio-tool-mount.c
@@ -1148,6 +1148,7 @@ handle_mount (int argc, char *argv[], gboolean do_help)
if (do_help)
{
show_help (context, NULL);
+ g_option_context_free (context);
return 0;
}
@@ -1155,6 +1156,7 @@ handle_mount (int argc, char *argv[], gboolean do_help)
{
show_help (context, error->message);
g_error_free (error);
+ g_option_context_free (context);
return 1;
}
diff --git a/gio/gio-tool-move.c b/gio/gio-tool-move.c
index acbe8e9..9f3c20b 100644
--- a/gio/gio-tool-move.c
+++ b/gio/gio-tool-move.c
@@ -113,12 +113,14 @@ handle_move (int argc, char *argv[], gboolean do_help)
{
show_help (context, error->message);
g_error_free (error);
+ g_option_context_free (context);
return 1;
}
if (argc < 3)
{
show_help (context, NULL);
+ g_option_context_free (context);
return 1;
}
@@ -128,6 +130,7 @@ handle_move (int argc, char *argv[], gboolean do_help)
{
show_help (context, NULL);
g_object_unref (dest);
+ g_option_context_free (context);
return 1;
}
@@ -140,6 +143,7 @@ handle_move (int argc, char *argv[], gboolean do_help)
show_help (context, message);
g_free (message);
g_object_unref (dest);
+ g_option_context_free (context);
return 1;
}
diff --git a/gio/gio-tool-open.c b/gio/gio-tool-open.c
index 9d0847e..217cf96 100644
--- a/gio/gio-tool-open.c
+++ b/gio/gio-tool-open.c
@@ -54,6 +54,7 @@ handle_open (int argc, char *argv[], gboolean do_help)
if (do_help)
{
show_help (context, NULL);
+ g_option_context_free (context);
return 0;
}
@@ -61,12 +62,14 @@ handle_open (int argc, char *argv[], gboolean do_help)
{
show_help (context, error->message);
g_error_free (error);
+ g_option_context_free (context);
return 1;
}
if (argc < 2)
{
show_help (context, _("No locations given"));
+ g_option_context_free (context);
return 1;
}
diff --git a/gio/gio-tool-remove.c b/gio/gio-tool-remove.c
index fafe176..b649fe8 100644
--- a/gio/gio-tool-remove.c
+++ b/gio/gio-tool-remove.c
@@ -55,6 +55,7 @@ handle_remove (int argc, char *argv[], gboolean do_help)
if (do_help)
{
show_help (context, NULL);
+ g_option_context_free (context);
return 0;
}
@@ -62,12 +63,14 @@ handle_remove (int argc, char *argv[], gboolean do_help)
{
show_help (context, error->message);
g_error_free (error);
+ g_option_context_free (context);
return 1;
}
if (argc == 1)
{
show_help (context, _("No locations given"));
+ g_option_context_free (context);
return 1;
}
diff --git a/gio/gio-tool-rename.c b/gio/gio-tool-rename.c
index 1f79745..9c36554 100644
--- a/gio/gio-tool-rename.c
+++ b/gio/gio-tool-rename.c
@@ -53,6 +53,7 @@ handle_rename (int argc, char *argv[], gboolean do_help)
if (do_help)
{
show_help (context, NULL);
+ g_option_context_free (context);
return 0;
}
@@ -60,17 +61,20 @@ handle_rename (int argc, char *argv[], gboolean do_help)
{
show_help (context, error->message);
g_error_free (error);
+ g_option_context_free (context);
return 1;
}
if (argc < 3)
{
show_help (context, _("Missing argument"));
+ g_option_context_free (context);
return 1;
}
if (argc > 3)
{
show_help (context, _("Too many arguments"));
+ g_option_context_free (context);
return 1;
}
diff --git a/gio/gio-tool-save.c b/gio/gio-tool-save.c
index 9dd6f9d..dc22242 100644
--- a/gio/gio-tool-save.c
+++ b/gio/gio-tool-save.c
@@ -171,6 +171,7 @@ handle_save (int argc, char *argv[], gboolean do_help)
if (do_help)
{
show_help (context, NULL);
+ g_option_context_free (context);
return 0;
}
@@ -178,18 +179,21 @@ handle_save (int argc, char *argv[], gboolean do_help)
{
show_help (context, error->message);
g_error_free (error);
+ g_option_context_free (context);
return 1;
}
if (argc < 2)
{
show_help (context, _("No destination given"));
+ g_option_context_free (context);
return 1;
}
if (argc > 2)
{
show_help (context, _("Too many arguments"));
+ g_option_context_free (context);
return 1;
}
diff --git a/gio/gio-tool-set.c b/gio/gio-tool-set.c
index e902b2b..87eea9d 100644
--- a/gio/gio-tool-set.c
+++ b/gio/gio-tool-set.c
@@ -96,6 +96,7 @@ handle_set (int argc, char *argv[], gboolean do_help)
if (do_help)
{
show_help (context, NULL);
+ g_option_context_free (context);
return 0;
}
@@ -103,18 +104,21 @@ handle_set (int argc, char *argv[], gboolean do_help)
{
show_help (context, error->message);
g_error_free (error);
+ g_option_context_free (context);
return 1;
}
if (argc < 2)
{
show_help (context, _("Location not specified"));
+ g_option_context_free (context);
return 1;
}
if (argc < 3)
{
show_help (context, _("Attribute not specified"));
+ g_option_context_free (context);
return 1;
}
@@ -124,12 +128,14 @@ handle_set (int argc, char *argv[], gboolean do_help)
if ((argc < 4) && (type != G_FILE_ATTRIBUTE_TYPE_INVALID))
{
show_help (context, _("Value not specified"));
+ g_option_context_free (context);
return 1;
}
if ((argc > 4) && (type != G_FILE_ATTRIBUTE_TYPE_STRINGV))
{
show_help (context, _("Too many arguments"));
+ g_option_context_free (context);
return 1;
}
diff --git a/gio/gio-tool-trash.c b/gio/gio-tool-trash.c
index 40f378c..7f9cc64 100644
--- a/gio/gio-tool-trash.c
+++ b/gio/gio-tool-trash.c
@@ -89,6 +89,7 @@ handle_trash (int argc, char *argv[], gboolean do_help)
if (do_help)
{
show_help (context, NULL);
+ g_option_context_free (context);
return 0;
}
@@ -96,6 +97,7 @@ handle_trash (int argc, char *argv[], gboolean do_help)
{
show_help (context, error->message);
g_error_free (error);
+ g_option_context_free (context);
return 1;
}
diff --git a/gio/gio-tool-tree.c b/gio/gio-tool-tree.c
index 415b399..d93d8c5 100644
--- a/gio/gio-tool-tree.c
+++ b/gio/gio-tool-tree.c
@@ -247,6 +247,7 @@ handle_tree (int argc, char *argv[], gboolean do_help)
if (do_help)
{
show_help (context, NULL);
+ g_option_context_free (context);
return 0;
}
@@ -256,6 +257,7 @@ handle_tree (int argc, char *argv[], gboolean do_help)
{
show_help (context, error->message);
g_error_free (error);
+ g_option_context_free (context);
return 1;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]