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:
Marco Trevisan (Treviño) 2022-06-21 04:59:54 +02:00
parent 576e5f2f87
commit 9c32cfbaaa

View File

@ -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;
}