[gnome-commander] Add null check for variable; free gnome_cmd_app object; free TmpDlData object correctly



commit 7aa20d83b3b19575d52ace88aa10220b3acf35c8
Author: Uwe Scholz <u scholz83 gmx de>
Date:   Wed Jul 21 23:21:24 2021 +0200

    Add null check for variable; free gnome_cmd_app object; free TmpDlData object correctly

 src/gnome-cmd-file-list.cc | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/src/gnome-cmd-file-list.cc b/src/gnome-cmd-file-list.cc
index f3456f3e..793fbdae 100644
--- a/src/gnome-cmd-file-list.cc
+++ b/src/gnome-cmd-file-list.cc
@@ -1220,6 +1220,11 @@ static void do_mime_exec_single (gpointer *args)
     auto dpath = (gchar *) args[2];
 
     auto gnomeCmdFile = gnome_cmd_file_new(path);
+
+    if (gnomeCmdFile == nullptr)
+        return;
+
+    gnome_cmd_file_ref(gnomeCmdFile);
     GList *gFileList = nullptr;
     gFileList = g_list_append(gFileList, gnomeCmdFile->gFile);
     g_app_info_launch (gnomeCmdFile->GetAppInfoForContentType(), gFileList, nullptr, nullptr);
@@ -1260,8 +1265,8 @@ static void on_tmp_download_response (GtkWidget *w, gint id, TmpDlData *dldata)
         g_free (dldata->args);
     }
 
-    g_free (dldata);
     gtk_widget_destroy (dldata->dialog);
+    g_free (dldata);
 }
 
 
@@ -1355,6 +1360,7 @@ static void mime_exec_single (GnomeCmdFile *f)
             g_app_info_launch (gAppInfo, gFileList, nullptr, nullptr);
             g_object_unref(gFileFromUri);
             g_list_free(gFileList);
+            gnome_cmd_app_free(app);
         }
         else
         {
@@ -1372,7 +1378,6 @@ static void mime_exec_single (GnomeCmdFile *f)
             g_free (msg);
         }
     }
-    gnome_cmd_app_free(app);
 }
 
 


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