From 24b63477d15ebd6bdc2cd47d3f63fb58c50b07cf Mon Sep 17 00:00:00 2001 From: Radek Doulik Date: Thu, 14 Feb 2002 20:18:05 +0000 Subject: fix case when priority is undefined and pri_a or pri_b is returned as 2002-02-14 Radek Doulik * e-summary-tasks.c (sort_uids): fix case when priority is undefined and pri_a or pri_b is returned as NULL, also fixes memory leak svn path=/trunk/; revision=15727 --- my-evolution/ChangeLog | 6 ++++++ my-evolution/e-summary-tasks.c | 20 +++++++++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/my-evolution/ChangeLog b/my-evolution/ChangeLog index 64a5c04b1a..4ebee50060 100644 --- a/my-evolution/ChangeLog +++ b/my-evolution/ChangeLog @@ -1,3 +1,9 @@ +2002-02-14 Radek Doulik + + * e-summary-tasks.c (sort_uids): fix case when priority is + undefined and pri_a or pri_b is returned as NULL, also fixes + memory leak + 2002-02-08 Damon Chaplin * e-summary-calendar.c (e_cal_comp_util_compare_event_timezones): diff --git a/my-evolution/e-summary-tasks.c b/my-evolution/e-summary-tasks.c index 6bcc65d2b7..51ab45c051 100644 --- a/my-evolution/e-summary-tasks.c +++ b/my-evolution/e-summary-tasks.c @@ -136,7 +136,8 @@ sort_uids (gconstpointer a, CalComponent *comp_a, *comp_b; CalClient *client = user_data; CalClientGetStatus status; - int real_a = 0, real_b = 0; + /* let undefined priorities be lowest ones */ + int lowest = 10, rv; int *pri_a, *pri_b; /* a after b then return > 0 */ @@ -149,13 +150,22 @@ sort_uids (gconstpointer a, if (status != CAL_CLIENT_GET_SUCCESS) return 1; - pri_a = &real_a; - pri_b = &real_b; - cal_component_get_priority (comp_a, &pri_a); cal_component_get_priority (comp_b, &pri_b); - return *pri_a - *pri_b; + if (pri_a == NULL) + pri_a = &lowest; + if (pri_b == NULL) + pri_b = &lowest; + + rv = *pri_a - *pri_b; + + if (pri_a != &lowest) + cal_component_free_priority (pri_a); + if (pri_b != &lowest) + cal_component_free_priority (pri_b); + + return rv; } static GList * -- cgit v1.2.3