mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-24 22:46:15 +01:00
gfileattribute: Do atomic addition before checking the old value on ref
So we avoid working on a value that is not been updated yet.
This commit is contained in:
parent
576e5f2f87
commit
9c32cfbaaa
@ -859,11 +859,12 @@ GFileAttributeInfoList *
|
||||
g_file_attribute_info_list_ref (GFileAttributeInfoList *list)
|
||||
{
|
||||
GFileAttributeInfoListPriv *priv = (GFileAttributeInfoListPriv *)list;
|
||||
int old_ref_count;
|
||||
|
||||
g_return_val_if_fail (list != NULL, NULL);
|
||||
g_return_val_if_fail (priv->ref_count > 0, NULL);
|
||||
|
||||
g_atomic_int_inc (&priv->ref_count);
|
||||
old_ref_count = g_atomic_int_add (&priv->ref_count, 1);
|
||||
g_return_val_if_fail (old_ref_count > 0, NULL);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user