From 409cd0dec1421ba69878454d52daead056493c5f Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Tue, 15 Oct 2024 11:51:59 -0700 Subject: [PATCH] Bug 799283 - Segfault/Crash if payment dialog change from customer to vendor Always take ownership of the text string. --- gnucash/gnome/business-gnome-utils.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gnucash/gnome/business-gnome-utils.c b/gnucash/gnome/business-gnome-utils.c index 835b22b39f3..4715337560c 100644 --- a/gnucash/gnome/business-gnome-utils.c +++ b/gnucash/gnome/business-gnome-utils.c @@ -450,14 +450,14 @@ gnc_account_select_combo_fill (GtkWidget *combo, QofBook *book, GtkListStore *store; GtkTreeIter iter; GList *list, *node; - const gchar *text; g_return_val_if_fail (combo && GTK_IS_COMBO_BOX(combo), NULL); g_return_val_if_fail (book, NULL); g_return_val_if_fail (acct_types, NULL); /* Figure out if anything is set in the combo */ - text = gtk_entry_get_text(GTK_ENTRY (gtk_bin_get_child(GTK_BIN (GTK_COMBO_BOX(combo))))); + char* text = + g_strdup (gtk_entry_get_text(GTK_ENTRY (gtk_bin_get_child(GTK_BIN (GTK_COMBO_BOX(combo)))))); g_object_set_data (G_OBJECT(combo), "book", book); list = gnc_account_get_descendants (gnc_book_get_root_account (book)); @@ -496,6 +496,7 @@ gnc_account_select_combo_fill (GtkWidget *combo, QofBook *book, /* Save the first account name in case no account name was set */ if (!text || g_strcmp0 (text, "") == 0) { + g_free (text); text = g_strdup (name); } g_free(name); @@ -506,6 +507,7 @@ gnc_account_select_combo_fill (GtkWidget *combo, QofBook *book, gnc_cbwe_set_by_string(GTK_COMBO_BOX(combo), text); + g_free (text); return gnc_account_select_combo_get_active (combo); }