gnucash stable: [gnc-gsettings.cpp] plug a char* leak

Christopher Lam clam at code.gnucash.org
Mon Jun 19 21:22:35 EDT 2023


Updated	 via  https://github.com/Gnucash/gnucash/commit/b331ec97 (commit)
	from  https://github.com/Gnucash/gnucash/commit/16640be6 (commit)



commit b331ec974e3b3d061a9de3edf91e31b2d1146d57
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon Jun 19 23:47:14 2023 +0800

    [gnc-gsettings.cpp] plug a char* leak
    
    full_name leaks if it's already in schema_hash hash table. It would be
    better to convert GHashTable to unordered_map.

diff --git a/libgnucash/app-utils/gnc-gsettings.cpp b/libgnucash/app-utils/gnc-gsettings.cpp
index 043d1c73a8..864b2c6a31 100644
--- a/libgnucash/app-utils/gnc-gsettings.cpp
+++ b/libgnucash/app-utils/gnc-gsettings.cpp
@@ -135,10 +135,11 @@ gnc_gsettings_register_cb (const gchar *schema, const gchar *key,
     {
         gs_obj = gnc_gsettings_get_settings_obj (schema);
         if (G_IS_SETTINGS (gs_obj))
-            g_hash_table_insert (schema_hash, full_name, gs_obj);
+            g_hash_table_insert (schema_hash, g_strdup (full_name), gs_obj);
         else
             PWARN ("Ignoring attempt to access unknown gsettings schema %s", full_name);
     }
+    g_free (full_name);
     g_return_val_if_fail (G_IS_SETTINGS (gs_obj), 0);
 
     auto signal = static_cast<char *> (nullptr);



Summary of changes:
 libgnucash/app-utils/gnc-gsettings.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)



More information about the gnucash-changes mailing list