[gnome-calendar/868-month-view-clicking-date-outside-of-month-in-agenda-list-makes-months-out-of-sync] gcal_set_date_time: Avoid possible use-after-free
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar/868-month-view-clicking-date-outside-of-month-in-agenda-list-makes-months-out-of-sync] gcal_set_date_time: Avoid possible use-after-free
- Date: Wed, 5 Oct 2022 15:05:40 +0000 (UTC)
commit 3c0311bb57a1682e0131d8e1d79e846afa77d0f8
Author: Milan Crha <mcrha redhat com>
Date: Wed Oct 5 16:59:30 2022 +0200
gcal_set_date_time: Avoid possible use-after-free
When the `*dest` and `src` are the same, doing g_date_time_unref()
can free the instance before it's assigned back to the `*dest`.
src/utils/gcal-date-time-utils.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/src/utils/gcal-date-time-utils.c b/src/utils/gcal-date-time-utils.c
index 06b3d17a..358ace8e 100644
--- a/src/utils/gcal-date-time-utils.c
+++ b/src/utils/gcal-date-time-utils.c
@@ -35,14 +35,15 @@ gboolean
gcal_set_date_time (GDateTime **dest,
GDateTime *src)
{
- gboolean changed = *dest != src;
+ if (*dest == src)
+ return FALSE;
gcal_clear_date_time (dest);
if (src)
*dest = g_date_time_ref (src);
- return changed;
+ return TRUE;
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]