summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOndrej Holy <oholy@redhat.com>2016-12-19 12:11:13 +0100
committerOndrej Holy <oholy@redhat.com>2017-04-10 10:14:04 +0200
commitfb7d2184a616553fdc1881fe52ebe2a3c7748280 (patch)
tree5af9b7feb6ec84fc64e1f1bc6f4d6e02fe251b8e
parent292f10d053c92d8908ef2d862ecb7672f0e0765a (diff)
downloadglib-fb7d2184a616553fdc1881fe52ebe2a3c7748280.tar.gz
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
-rw-r--r--gio/gio-tool-cat.c3
-rw-r--r--gio/gio-tool-copy.c5
-rw-r--r--gio/gio-tool-info.c3
-rw-r--r--gio/gio-tool-list.c2
-rw-r--r--gio/gio-tool-mime.c3
-rw-r--r--gio/gio-tool-mkdir.c3
-rw-r--r--gio/gio-tool-monitor.c3
-rw-r--r--gio/gio-tool-mount.c2
-rw-r--r--gio/gio-tool-move.c4
-rw-r--r--gio/gio-tool-open.c3
-rw-r--r--gio/gio-tool-remove.c3
-rw-r--r--gio/gio-tool-rename.c4
-rw-r--r--gio/gio-tool-save.c4
-rw-r--r--gio/gio-tool-set.c6
-rw-r--r--gio/gio-tool-trash.c2
-rw-r--r--gio/gio-tool-tree.c2
16 files changed, 52 insertions, 0 deletions
diff --git a/gio/gio-tool-cat.c b/gio/gio-tool-cat.c
index 3dc02d192..d09fbda2f 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 c64fd4e78..706827c89 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 570322d05..9cd2ea227 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 528024fb8..116ed1fe6 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 ead2f12bb..865416664 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 6e955a8c3..060e5684c 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 cfdcdbfd3..c9d878a6d 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 50ee5cde2..e04004aca 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 acbe8e954..9f3c20b66 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 9d0847eb5..217cf9624 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 fafe176f8..b649fe857 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 1f79745d6..9c3655444 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 9dd6f9d56..dc222422d 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 e902b2b08..87eea9d1f 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 40f378c8f..7f9cc6499 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 415b3990b..d93d8c5b7 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;
}