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:
committed by
Georges Basile Stavracas Neto
parent
80d803d125
commit
d273b4304f
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user