[file-roller/wip/jtojnar/engrampa-backports: 1/4] nautilus-fileroller: fixed memleaks, removed useless code




commit d5ecd6a2add531b0d7bdbcb99fe84b0ad45d4713
Author: Jan Tojnar <jtojnar gmail com>
Date:   Tue Jul 26 16:41:27 2022 +0200

    nautilus-fileroller: fixed memleaks, removed useless code
    
    Based on https://github.com/mate-desktop/engrampa/commit/49f8fe9f3275c7e094472d93991f7b33a45f3a84
    Co-Authored-By: Monsta <monsta inbox ru>

 nautilus/nautilus-fileroller.c | 27 +++++++++++----------------
 1 file changed, 11 insertions(+), 16 deletions(-)
---
diff --git a/nautilus/nautilus-fileroller.c b/nautilus/nautilus-fileroller.c
index 2f4e9e48..d10e83e1 100644
--- a/nautilus/nautilus-fileroller.c
+++ b/nautilus/nautilus-fileroller.c
@@ -41,6 +41,8 @@ extract_to_callback (NautilusMenuItem *item,
        NautilusFileInfo *file;
        char             *uri, *default_dir;
        GString          *cmd;
+       g_autofree char *quoted_uri = NULL;
+       g_autofree char *quoted_default_dir = NULL;
 
        files = g_object_get_data (G_OBJECT (item), "files");
        file = files->data;
@@ -48,11 +50,14 @@ extract_to_callback (NautilusMenuItem *item,
        uri = nautilus_file_info_get_uri (file);
        default_dir = nautilus_file_info_get_parent_uri (file);
 
+       quoted_uri = g_shell_quote (uri);
+       quoted_default_dir = g_shell_quote (default_dir);
+
        cmd = g_string_new ("file-roller");
        g_string_append_printf (cmd,
                                " --default-dir=%s --extract %s",
-                               g_shell_quote (default_dir),
-                               g_shell_quote (uri));
+                               quoted_default_dir,
+                               quoted_uri);
 
 #ifdef DEBUG
        g_print ("EXEC: %s\n", cmd->str);
@@ -71,27 +76,17 @@ extract_here_callback (NautilusMenuItem *item,
                       gpointer          user_data)
 {
        GList            *files, *scan;
-       NautilusFileInfo *file;
-       char             *dir;
        GString          *cmd;
 
        files = g_object_get_data (G_OBJECT (item), "files");
-       file = files->data;
 
-       dir = nautilus_file_info_get_parent_uri (file);
-
-       cmd = g_string_new ("file-roller");
-       g_string_append_printf (cmd," --extract-here --notify");
-
-       g_free (dir);
+       cmd = g_string_new ("file-roller --extract-here --notify");
 
        for (scan = files; scan; scan = scan->next) {
                NautilusFileInfo *file = scan->data;
-               char             *uri;
-
-               uri = nautilus_file_info_get_uri (file);
-               g_string_append_printf (cmd, " %s", g_shell_quote (uri));
-               g_free (uri);
+               g_autofree char *uri = nautilus_file_info_get_uri (file);
+               g_autofree char *quoted_uri = g_shell_quote (uri);
+               g_string_append_printf (cmd, " %s", quoted_uri);
        }
 
        g_spawn_command_line_async (cmd->str, NULL);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]