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`.
This commit is contained in:
Milan Crha
2022-10-05 15:10:47 +00:00
committed by Georges Basile Stavracas Neto
parent 80d803d125
commit d273b4304f
+3 -2
View File
@@ -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;
}
/**