gnucash maint: Close some more memory leaks

Phil Longstaff plongstaff at code.gnucash.org
Sun Feb 28 16:33:39 EST 2016


Updated	 via  https://github.com/Gnucash/gnucash/commit/97b7c265 (commit)
	from  https://github.com/Gnucash/gnucash/commit/40c543ef (commit)



commit 97b7c26570092d8651f7ea391029ab88fc2cee26
Author: Phil Longstaff <phil.longstaff at yahoo.ca>
Date:   Sun Feb 28 07:31:03 2016 -0500

    Close some more memory leaks

diff --git a/src/app-utils/gnc-state.c b/src/app-utils/gnc-state.c
index 2896717..30edce9 100644
--- a/src/app-utils/gnc-state.c
+++ b/src/app-utils/gnc-state.c
@@ -147,7 +147,7 @@ gnc_state_set_base (const QofSession *session)
             {
                 DEBUG ("Trying old state file names for compatibility");
                 i = 1;
-                g_free ( sf_extension);
+                g_free (sf_extension);
                 sf_extension = g_strdup ("");
 
                 /* Regardless of whether or not an old state file is found,
@@ -190,6 +190,7 @@ gnc_state_set_base (const QofSession *session)
     }
 
     DEBUG("Clean up");
+    g_free(sf_extension);
     g_free(original);
     g_key_file_free (key_file);
 
diff --git a/src/core-utils/gnc-filepath-utils.c b/src/core-utils/gnc-filepath-utils.c
index edf2cc5..9019c75 100644
--- a/src/core-utils/gnc-filepath-utils.c
+++ b/src/core-utils/gnc-filepath-utils.c
@@ -457,8 +457,8 @@ gnc_dotgnucash_dir (void)
     if (!gnc_validate_directory(tmp_dir, TRUE, &errmsg))
         exit(1);
     g_free(tmp_dir);
-    tmp_dir = g_build_filename(tmp_dir, "translog", (gchar *)NULL);
-    if (!gnc_validate_directory(dotgnucash, TRUE, &errmsg))
+    tmp_dir = g_build_filename(dotgnucash, "translog", (gchar *)NULL);
+    if (!gnc_validate_directory(tmp_dir, TRUE, &errmsg))
         exit(1);
     g_free(tmp_dir);
 
diff --git a/src/gnome-utils/gnc-plugin-menu-additions.c b/src/gnome-utils/gnc-plugin-menu-additions.c
index 89c12b2..21a6d7f 100644
--- a/src/gnome-utils/gnc-plugin-menu-additions.c
+++ b/src/gnome-utils/gnc-plugin-menu-additions.c
@@ -325,6 +325,7 @@ gnc_menu_additions_assign_accel (ExtensionInfo *info, GHashTable *table)
     const gchar *ptr;
     gunichar uni;
     gint len;
+    gboolean map_allocated = FALSE;
 
     ENTER("Checking %s/%s [%s]", info->path, info->ae.label, info->ae.name);
     if (info->accel_assigned)
@@ -336,7 +337,10 @@ gnc_menu_additions_assign_accel (ExtensionInfo *info, GHashTable *table)
     /* Get map of used keys */
     map = g_hash_table_lookup(table, info->path);
     if (map == NULL)
+    {
         map = g_strdup("");
+        map_allocated = TRUE;
+    }
     DEBUG("map '%s', path %s", map, info->path);
 
     for (ptr = info->ae.label; *ptr; ptr = g_utf8_next_char(ptr))
@@ -356,6 +360,10 @@ gnc_menu_additions_assign_accel (ExtensionInfo *info, GHashTable *table)
     {
         /* Ran out of characters. Nothing to do. */
         info->accel_assigned = TRUE;
+        if (map_allocated)
+        {
+            g_free(map);
+        }
         LEAVE("All characters already assigned");
         return;
     }
@@ -375,6 +383,10 @@ gnc_menu_additions_assign_accel (ExtensionInfo *info, GHashTable *table)
     g_hash_table_replace(table, info->path, new_map);
 
     info->accel_assigned = TRUE;
+    if (map_allocated)
+    {
+        g_free(map);
+    }
     LEAVE("assigned");
 }
 



Summary of changes:
 src/app-utils/gnc-state.c                   |  3 ++-
 src/core-utils/gnc-filepath-utils.c         |  4 ++--
 src/gnome-utils/gnc-plugin-menu-additions.c | 12 ++++++++++++
 3 files changed, 16 insertions(+), 3 deletions(-)



More information about the gnucash-changes mailing list