From 8fa197eebf1e5775fb4a2f0fc06aee01347bc15a Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Wed, 2 Mar 2022 15:04:26 +0800 Subject: [PATCH] [gnc-budget-view] total_nodes may be exhausted. assign NULL. the refactor in 8cef481e1 introduced a crasher -- in the line totals_view_col = gtk_tree_view_get_column (priv->totals_tree_view, j); j would occasionally exceed the number of columns available in the GtkTreeView and the function would return NULL. This change restores this behaviour. I found that switching preference Account -> Default currency radio buttons would trigger this crasher. To illustrate, add the following tracer immediately after assigning totals_view_col. PWARN ("tree_view_col=%p, totals_view_col=%p", tree_view_col, totals_view_col) --- gnucash/gnome/gnc-budget-view.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gnucash/gnome/gnc-budget-view.c b/gnucash/gnome/gnc-budget-view.c index 3a0c24c07c..a7dfdf5b94 100644 --- a/gnucash/gnome/gnc-budget-view.c +++ b/gnucash/gnome/gnc-budget-view.c @@ -884,7 +884,7 @@ gbv_treeview_resized_cb (GtkWidget *widget, GtkAllocation *allocation, if ((g_strcmp0 (name, "description") == 0) && (!priv->show_account_desc)) total_node = g_list_next (total_node); - if (gtk_tree_view_column_get_visible (tree_view_col)) + if (gtk_tree_view_column_get_visible (tree_view_col) && total_node != NULL) { gint col_width = gtk_tree_view_column_get_width (tree_view_col); GtkTreeViewColumn *totals_view_col = total_node->data;