Skip to content

Commit

Permalink
g_free strings allocated with gnc_prefs_get_string
Browse files Browse the repository at this point in the history
gnc_prefs_get_string will return a newly-allocated string. after use,
they must be g_freed.
  • Loading branch information
christopherlam committed Sep 2, 2020
1 parent de33d1e commit fb42065
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions gnucash/gnome-utils/dialog-file-access.c
Expand Up @@ -343,6 +343,7 @@ gnc_ui_file_access (GtkWindow *parent, int type)
faw->starting_dir = g_path_get_dirname( filepath );
g_free ( filepath );
}
g_free (last);
}
if (!faw->starting_dir)
faw->starting_dir = gnc_get_default_directory(settings_section);
Expand Down
12 changes: 10 additions & 2 deletions gnucash/gnome-utils/gnc-plugin-file-history.c
Expand Up @@ -256,6 +256,7 @@ gnc_history_remove_file (const char *oldfile)
}
j++;
}
g_free (filename);
}
g_free(from);
}
Expand Down Expand Up @@ -283,12 +284,18 @@ gboolean gnc_history_test_for_file (const char *oldfile)
filename = gnc_prefs_get_string(GNC_PREFS_GROUP_HISTORY, from);
g_free(from);

if (filename && (g_utf8_collate(oldfile, filename) == 0))
if (!filename)
continue;

if (g_utf8_collate(oldfile, filename) == 0)
{
found = TRUE;
g_free (filename);
break;
}
g_free (filename);
}

return found;
}

Expand Down Expand Up @@ -488,7 +495,7 @@ gnc_plugin_history_list_changed (gpointer prefs,
gpointer user_data)
{
GncMainWindow *window;
const gchar *filename;
gchar *filename;
gint index;

ENTER("");
Expand All @@ -509,6 +516,7 @@ gnc_plugin_history_list_changed (gpointer prefs,

filename = gnc_prefs_get_string (GNC_PREFS_GROUP_HISTORY, pref);
gnc_history_update_action (window, index, filename);
g_free (filename);

gnc_main_window_actions_updated (window);
LEAVE("");
Expand Down
5 changes: 5 additions & 0 deletions gnucash/gnome/dialog-print-check.c
Expand Up @@ -609,8 +609,11 @@ gnc_ui_print_restore_dialog(PrintCheckDialog *pcd)
if (guid == NULL)
gtk_combo_box_set_active(GTK_COMBO_BOX(pcd->format_combobox), 0);
else if (strcmp(guid, "custom") == 0)
{
gtk_combo_box_set_active(GTK_COMBO_BOX(pcd->format_combobox),
pcd->format_max - 1);
g_free (guid);
}
else
{
model = gtk_combo_box_get_model(GTK_COMBO_BOX(pcd->format_combobox));
Expand All @@ -622,7 +625,9 @@ gnc_ui_print_restore_dialog(PrintCheckDialog *pcd)
{
gtk_combo_box_set_active(GTK_COMBO_BOX(pcd->format_combobox), 0);
}
g_free (guid);
}

active = gnc_prefs_get_int(GNC_PREFS_GROUP, GNC_PREF_CHECK_POSITION);

/* If the check format used last time no longer exists, then the saved check
Expand Down

0 comments on commit fb42065

Please sign in to comment.