[gnome-calendar/mcatanzaro/#434-gnome-3-32] Don't leave dangling pointers in the GcalEvent cache
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar/mcatanzaro/#434-gnome-3-32] Don't leave dangling pointers in the GcalEvent cache
- Date: Wed, 17 Jul 2019 00:53:44 +0000 (UTC)
commit ad588e95adaff5e06841ac516621fd8d10757075
Author: Michael Catanzaro <mcatanzaro igalia com>
Date: Tue Jul 16 19:40:06 2019 -0500
Don't leave dangling pointers in the GcalEvent cache
The cache has an unowned pointer to the GcalEvent's UID. We need to
update the cache with the GcalEvent's new UID to avoid use-after-free.
Fixes #434
src/gcal-event.c | 6 ++++++
1 file changed, 6 insertions(+)
---
diff --git a/src/gcal-event.c b/src/gcal-event.c
index e8eada98..3d8df82b 100644
--- a/src/gcal-event.c
+++ b/src/gcal-event.c
@@ -265,6 +265,9 @@ gcal_event_update_uid_internal (GcalEvent *self)
id = e_cal_component_get_id (self->component);
/* Clear the previous uid */
+ g_debug ("Removing '%s' (%p) from cache", self->uid, self);
+ g_hash_table_remove (event_cache, self->uid);
+
g_clear_pointer (&self->uid, g_free);
if (id->rid != NULL)
@@ -281,6 +284,9 @@ gcal_event_update_uid_internal (GcalEvent *self)
id->uid);
}
+ g_debug ("Adding %s to the cache", self->uid);
+ g_hash_table_insert (event_cache, self->uid, self);
+
e_cal_component_free_id (id);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_UID]);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]