[memprof: 63/76] main.c: Fix a crash when clearing a profile



commit 09b269e0b7b6e2f197234e64cf6486711d996d03
Author: Holger Hans Peter Freyther <zecke selfish org>
Date:   Mon Jan 18 06:28:14 2010 +0100

    main.c: Fix a crash when clearing a profile
    
    In the case the user has generated a profile and then
    is pressing the swipe button we will crash. This is because
    the selection_changed callback will be called and we try
    to access the profile and then will crash.
    
    Change the code to check for n_bytes only after we have
    checked if there is a selection. This is fixing the crash.

 src/main.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
---
diff --git a/src/main.c b/src/main.c
index 551ed43..02b19ed 100644
--- a/src/main.c
+++ b/src/main.c
@@ -390,7 +390,7 @@ profile_selection_changed (GtkTreeSelection *selection, ProcessWindow *pwin)
 	GPtrArray *caller_list;
 	ProfileDescendantTree *descendant_tree;
 	int i;
-	int n_samples = pwin->profile->n_bytes;
+	int n_samples;
 	int old_sort_column;
 	GtkSortType old_sort_type;
 	gboolean was_sorted;
@@ -401,6 +401,7 @@ profile_selection_changed (GtkTreeSelection *selection, ProcessWindow *pwin)
 		return;
 	}
 
+	n_samples = pwin->profile->n_bytes;
 	gtk_tree_model_get (GTK_TREE_MODEL (store), &selected,
 			    PROFILE_FUNC_FUNC, &func,
 			    -1);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]