Skip to content

Commit

Permalink
Bug 799283 - Segfault/Crash if payment dialog change from customer to…
Browse files Browse the repository at this point in the history
… vendor

Always take ownership of the text string.
  • Loading branch information
christopherlam authored and jralls committed Oct 15, 2024
1 parent f556881 commit 409cd0d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions gnucash/gnome/business-gnome-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}

Expand Down

0 comments on commit 409cd0d

Please sign in to comment.