diff --git a/src/core-utils/gnc-gtk-utils.c b/src/core-utils/gnc-gtk-utils.c index 52a58fb3c9..964b67c550 100644 --- a/src/core-utils/gnc-gtk-utils.c +++ b/src/core-utils/gnc-gtk-utils.c @@ -43,8 +43,9 @@ gnc_cbe_set_by_string(GtkComboBoxEntry *cbe, { GtkTreeModel *model; GtkTreeIter iter; - const gchar *tree_string; + gchar *tree_string; gint column, index, id; + gboolean match; model = gtk_combo_box_get_model(GTK_COMBO_BOX(cbe)); if (!gtk_tree_model_get_iter_first(model, &iter)) { @@ -56,7 +57,9 @@ gnc_cbe_set_by_string(GtkComboBoxEntry *cbe, column = gtk_combo_box_entry_get_text_column(cbe); do { gtk_tree_model_get(model, &iter, column, &tree_string, -1); - if (g_utf8_collate(text, tree_string) != 0) + match = g_utf8_collate(text, tree_string) == 0; + g_free(tree_string); + if (!match) continue; /* Found a matching string */ @@ -120,6 +123,7 @@ gnc_cbe_match_selected_cb (GtkEntryCompletion *completion, column = gtk_combo_box_entry_get_text_column(cbe); gtk_tree_model_get(comp_model, comp_iter, column, &text, -1); gnc_cbe_set_by_string(cbe, text); + g_free(text); return FALSE; } diff --git a/src/gnome-utils/druid-gnc-xml-import.c b/src/gnome-utils/druid-gnc-xml-import.c index b5d73df018..a2175c71bd 100644 --- a/src/gnome-utils/druid-gnc-xml-import.c +++ b/src/gnome-utils/druid-gnc-xml-import.c @@ -1113,6 +1113,7 @@ gxi_default_enc_combo_changed_cb (GtkComboBox *combo, GncXmlImportData *data) gtk_tree_model_get (gtk_combo_box_get_model (combo), &iter, 0, &enc_string, -1); curr_enc = g_quark_from_string (enc_string); + g_free (enc_string); if (data->default_encoding == curr_enc) return; diff --git a/src/gnome-utils/gnc-tree-view-account.c b/src/gnome-utils/gnc-tree-view-account.c index 06527c368e..ce56367a6a 100644 --- a/src/gnome-utils/gnc-tree-view-account.c +++ b/src/gnome-utils/gnc-tree-view-account.c @@ -270,7 +270,7 @@ sort_by_string (GtkTreeModel *f_model, GtkTreeModel *model; GtkTreeIter iter1, iter2; const Account *account1, *account2; - const gchar *str1, *str2; + gchar *str1, *str2; gint column = GPOINTER_TO_INT(user_data); gint result; @@ -281,6 +281,8 @@ sort_by_string (GtkTreeModel *f_model, gtk_tree_model_get(GTK_TREE_MODEL(model), &iter2, column, &str2, -1); result = safe_utf8_collate(str1, str2); + g_free(str1); + g_free(str2); if (result != 0) return result; return xaccAccountOrder(account1, account2); diff --git a/src/gnome-utils/gnc-tree-view-commodity.c b/src/gnome-utils/gnc-tree-view-commodity.c index 950b094140..07d9a40f8b 100644 --- a/src/gnome-utils/gnc-tree-view-commodity.c +++ b/src/gnome-utils/gnc-tree-view-commodity.c @@ -277,7 +277,7 @@ sort_by_commodity_string (GtkTreeModel *f_model, GtkTreeModel *model; GtkTreeIter iter_a, iter_b; gnc_commodity *comm_a, *comm_b; - const gchar *str1, *str2; + gchar *str1, *str2; gint column = GPOINTER_TO_INT(user_data); gint result; @@ -290,6 +290,8 @@ sort_by_commodity_string (GtkTreeModel *f_model, gtk_tree_model_get(GTK_TREE_MODEL(model), &iter_b, column, &str2, -1); result = safe_utf8_collate(str1, str2); + g_free(str1); + g_free(str2); if (result != 0) return result; return default_sort(comm_a, comm_b); diff --git a/src/import-export/csv/gnc-csv-import.c b/src/import-export/csv/gnc-csv-import.c index 0ed5bb5807..68eec7bc37 100644 --- a/src/import-export/csv/gnc-csv-import.c +++ b/src/import-export/csv/gnc-csv-import.c @@ -253,6 +253,7 @@ static void ok_button_clicked(GtkWidget* widget, GncCsvPreview* preview) for(i = 0; i < ncols; i++) { int type; /* The column type contained in this column. */ + gboolean found; gchar* contents; /* The column type string in this column. */ /* Get the type string first. (store is arranged so that every two * columns is a pair of the model used for the combobox and the @@ -264,7 +265,9 @@ static void ok_button_clicked(GtkWidget* widget, GncCsvPreview* preview) for(type = 0; type < GNC_CSV_NUM_COL_TYPES; type++) { /* ... we find one that matches with what's in the column. */ - if(!strcmp(contents, _(gnc_csv_column_type_strs[type]))) + found = !strcmp(contents, _(gnc_csv_column_type_strs[type])); + g_free(contents); + if(found) { /* Set the column_types array appropriately and quit. */ column_types->data[i] = type; @@ -369,6 +372,7 @@ static void column_type_edited(GtkCellRenderer* renderer, gchar* path, gtk_list_store_set(GTK_LIST_STORE(store), &iter, 2*i+1, _(gnc_csv_column_type_strs[GNC_CSV_NONE]), -1); } + g_free(contents); } else /* If this is the column that was edited ... */ { diff --git a/src/import-export/qif-import/dialog-account-picker.c b/src/import-export/qif-import/dialog-account-picker.c index 8ae0df0610..22892c5fb4 100644 --- a/src/import-export/qif-import/dialog-account-picker.c +++ b/src/import-export/qif-import/dialog-account-picker.c @@ -199,12 +199,10 @@ gnc_ui_qif_account_picker_changed_cb (GtkTreeSelection *selection, SCM name_setter = scm_c_eval_string("qif-map-entry:set-gnc-name!"); GtkTreeModel *model; GtkTreeIter iter; - gchar *name; g_free(wind->selected_name); if (gtk_tree_selection_get_selected(selection, &model, &iter)) { - gtk_tree_model_get(model, &iter, ACCOUNT_COL_FULLNAME, &name, -1); - wind->selected_name = g_strdup(name); + gtk_tree_model_get(model, &iter, ACCOUNT_COL_FULLNAME, &wind->selected_name, -1); scm_call_2(name_setter, wind->map_entry, scm_makfrom0str(wind->selected_name)); } else { wind->selected_name = NULL; diff --git a/src/register/register-gnome/gnucash-item-list.c b/src/register/register-gnome/gnucash-item-list.c index bac391f9d7..55c38ccad7 100644 --- a/src/register/register-gnome/gnucash-item-list.c +++ b/src/register/register-gnome/gnucash-item-list.c @@ -124,9 +124,12 @@ _gnc_item_find_selection(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *it { FindSelectionData *to_find = (FindSelectionData*)data; gchar *iterStr; + gboolean found; gtk_tree_model_get(model, iter, 0, &iterStr, -1); - if (safe_strcmp(to_find->string_to_find, iterStr) == 0) + found = safe_strcmp(to_find->string_to_find, iterStr) == 0; + g_free(iterStr); + if (found) { to_find->found_path = gtk_tree_path_copy(path); return TRUE; @@ -283,7 +286,7 @@ gnc_item_list_button_event(GtkWidget *widget, GdkEventButton *event, gnc_item_list_signals[ACTIVATE_ITEM], 0, string); - + g_free(string); return TRUE; default: return FALSE; @@ -313,6 +316,7 @@ gnc_item_list_key_event (GtkWidget *widget, GdkEventKey *event, gpointer data) gnc_item_list_signals[ACTIVATE_ITEM], 0, string); + g_free(string); return TRUE; case GDK_Page_Up: diff --git a/src/report/report-gnome/dialog-style-sheet.c b/src/report/report-gnome/dialog-style-sheet.c index 45a7cb8b95..e854bd9596 100644 --- a/src/report/report-gnome/dialog-style-sheet.c +++ b/src/report/report-gnome/dialog-style-sheet.c @@ -303,6 +303,7 @@ gnc_style_sheet_select_dialog_response_cb (GtkDialog *unused, gtk_list_store_set (ss->list_store, &iter, COLUMN_DIALOG, ssinfo, -1); + g_free(name); } break;