[gnome-commander] Initiate GError with nullptr; free unused memory



commit e2f3ebbd52a16048632bcabecb7a0ca2bcc9f4d2
Author: Uwe Scholz <u scholz83 gmx de>
Date:   Thu Jul 22 23:27:12 2021 +0200

    Initiate GError with nullptr; free unused memory

 src/gnome-cmd-file.cc | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/src/gnome-cmd-file.cc b/src/gnome-cmd-file.cc
index b8bc50a0..99a8e874 100644
--- a/src/gnome-cmd-file.cc
+++ b/src/gnome-cmd-file.cc
@@ -170,7 +170,8 @@ GnomeCmdFile *gnome_cmd_file_new (GFileInfo *gFileInfo, GnomeCmdDir *dir)
 GnomeCmdFile *gnome_cmd_file_new_from_gfile (GFile *gFile)
 {
     g_return_val_if_fail (gFile != nullptr, nullptr);
-    GError *error;
+    g_return_val_if_fail (G_IS_FILE(gFile), nullptr);
+    GError *error = nullptr;
 
     auto gFileInfo = g_file_query_info(gFile, "*", G_FILE_QUERY_INFO_NONE, nullptr, &error);
     if (!gFileInfo || error)
@@ -591,8 +592,9 @@ GFile *GnomeCmdFile::get_gfile(const gchar *name)
         else
             g_assert ("Non directory file without owning directory");
     }
-
-    return gnome_cmd_dir_get_child_gfile (::get_parent_dir (this), name ? name : g_file_get_basename(gFile));
+    auto filename = g_file_get_basename(gFile);
+    return gnome_cmd_dir_get_child_gfile (::get_parent_dir (this), name ? name : filename);
+    g_free(filename);
 }
 
 


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