[gnome-todo] gtd-task: Fix leak of ECalComponentDateTime



commit ac5a6753b6ba4583e7f443fb11f1361055329740
Author: Victor Toso <me victortoso com>
Date:   Thu Oct 27 23:19:09 2016 +0200

    gtd-task: Fix leak of ECalComponentDateTime
    
    As the document states on e_cal_component_get_due:
    
     "Return value for the due date/time. This should be freed with the
      e_cal_component_free_datetime() function."
    
    3,168 bytes in 66 blocks are definitely lost in loss record 15,883 of 16,044
       at 0x4C2DB9D: malloc (vg_replace_malloc.c:299)
       by 0xA5229D5: g_malloc (gmem.c:94)
       by 0xA522CB7: g_malloc_n (gmem.c:331)
       by 0x5BE62D6: get_datetime (e-cal-component.c:2515)
       by 0x5BE70B7: e_cal_component_get_due (e-cal-component.c:2841)
       by 0x4259A3: gtd_task_get_due_date (gtd-task.c:949)
       by 0x435A61: gtd_panel_scheduled_count_tasks (gtd-panel-scheduled.c:311)
    
    Signed-off-by: Victor Toso <victortoso redhat com>
    
    https://bugzilla.gnome.org/show_bug.cgi?id=773606

 src/gtd-task.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
---
diff --git a/src/gtd-task.c b/src/gtd-task.c
index a06e4da..7c63894 100644
--- a/src/gtd-task.c
+++ b/src/gtd-task.c
@@ -941,6 +941,7 @@ gtd_task_get_due_date (GtdTask *task)
 {
   ECalComponentDateTime comp_dt;
   GtdTaskPrivate *priv;
+  GDateTime *date;
 
   g_return_val_if_fail (GTD_IS_TASK (task), NULL);
 
@@ -948,7 +949,9 @@ gtd_task_get_due_date (GtdTask *task)
 
   e_cal_component_get_due (priv->component, &comp_dt);
 
-  return gtd_task__convert_icaltime (comp_dt.value);
+  date = gtd_task__convert_icaltime (comp_dt.value);
+  e_cal_component_free_datetime (&comp_dt);
+  return date;
 }
 
 /**


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