gio-tool: Various memory leak fixes

https://bugzilla.gnome.org/show_bug.cgi?id=776169
This commit is contained in:
Ondrej Holy 2016-12-16 14:35:55 +01:00
parent 0beeeb2ec9
commit bde2bde411
3 changed files with 8 additions and 2 deletions

View File

@ -254,6 +254,7 @@ get_writable_info (GFile *file)
list->infos[i].name, list->infos[i].name,
attribute_type_to_string (list->infos[i].type), attribute_type_to_string (list->infos[i].type),
(*flags != 0)?", ":"", flags); (*flags != 0)?", ":"", flags);
g_free (flags);
} }
} }

View File

@ -176,12 +176,14 @@ add_watch (const gchar *cmdline,
g_signal_connect (monitor, "changed", G_CALLBACK (watch_callback), g_strdup (cmdline)); g_signal_connect (monitor, "changed", G_CALLBACK (watch_callback), g_strdup (cmdline));
monitor = NULL; /* leak */ monitor = NULL; /* leak */
g_object_unref (file);
return TRUE; return TRUE;
err: err:
print_file_error (file, error->message); print_file_error (file, error->message);
g_error_free (error); g_error_free (error);
g_object_unref (file);
return FALSE; return FALSE;
} }

View File

@ -112,8 +112,6 @@ handle_set (int argc, char *argv[], gboolean do_help)
return 1; return 1;
} }
file = g_file_new_for_commandline_arg (argv[1]);
if (argc < 3) if (argc < 3)
{ {
show_help (context, _("Attribute not specified")); show_help (context, _("Attribute not specified"));
@ -177,6 +175,8 @@ handle_set (int argc, char *argv[], gboolean do_help)
return 1; return 1;
} }
file = g_file_new_for_commandline_arg (argv[1]);
if (!g_file_set_attribute (file, if (!g_file_set_attribute (file,
attribute, attribute,
type, type,
@ -188,8 +188,11 @@ handle_set (int argc, char *argv[], gboolean do_help)
{ {
print_error (error->message); print_error (error->message);
g_error_free (error); g_error_free (error);
g_object_unref (file);
return 1; return 1;
} }
g_object_unref (file);
return 0; return 0;
} }