[gnome-calendar/gnome-3-22] window: Fix leak of event_creation_data struct



commit 0ed3a0d60988b30aa9cf30bdb0d3f4d75a1dd637
Author: Victor Toso <me victortoso com>
Date:   Mon Oct 3 21:31:45 2016 +0200

    window: Fix leak of event_creation_data struct
    
    And also be sure to set its pointer to NULL by using g_clear_pointer()
    
    8,830 (24 direct, 8,806 indirect) bytes in 1 blocks are
    definitely lost in loss record 17,999 of 18,078
       at 0x4C2FA50: calloc (vg_replace_malloc.c:711)
       by 0x99CE981: g_malloc0 (gmem.c:124)
       by 0x99CEC64: g_malloc0_n (gmem.c:355)
       by 0x44CD43: show_new_event_widget (gcal-window.c:731)
       by 0x976FC57: ffi_call_unix64 (in /usr/lib64/libffi.so.6.0.2)
       by 0x976F6B9: ffi_call (in /usr/lib64/libffi.so.6.0.2)
       by 0x952703B: g_cclosure_marshal_generic (gclosure.c:1490)
       by 0x95258B9: g_closure_invoke (gclosure.c:804)
       by 0x9541D25: signal_emit_unlocked_R (gsignal.c:3635)
       by 0x954105C: g_signal_emit_valist (gsignal.c:3391)
       by 0x954170B: g_signal_emit_by_name (gsignal.c:3487)
       by 0x4324D8: show_popover_for_position (gcal-month-view.c:305)
    
    https://bugzilla.gnome.org/show_bug.cgi?id=772379

 src/gcal-window.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
---
diff --git a/src/gcal-window.c b/src/gcal-window.c
index 57ad392..5bc2bbb 100644
--- a/src/gcal-window.c
+++ b/src/gcal-window.c
@@ -725,7 +725,7 @@ show_new_event_widget (GcalView   *view,
     {
       g_clear_pointer (&window->event_creation_data->start_date, g_date_time_unref);
       g_clear_pointer (&window->event_creation_data->end_date, g_date_time_unref);
-      g_free (window->event_creation_data);
+      g_clear_pointer (&window->event_creation_data, g_free);
     }
 
   window->event_creation_data = g_new0 (NewEventData, 1);
@@ -1468,6 +1468,13 @@ gcal_window_finalize (GObject *object)
       g_clear_object (&window->event_to_delete);
     }
 
+  if (window->event_creation_data != NULL)
+    {
+      g_clear_pointer (&window->event_creation_data->start_date, g_date_time_unref);
+      g_clear_pointer (&window->event_creation_data->end_date, g_date_time_unref);
+      g_clear_pointer (&window->event_creation_data, g_free);
+    }
+
   g_clear_object (&window->manager);
   g_clear_object (&window->views_switcher);
 


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