diff options
author | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2022-06-21 04:59:54 +0200 |
---|---|---|
committer | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2022-06-23 20:01:12 +0200 |
commit | 9c32cfbaaa42a89d4d69d62dccd931cf065c53ee (patch) | |
tree | 002e6d118aacceed9e2247e829ac0ab1d146612c | |
parent | 576e5f2f875125c4ee06505790da22a2878c9198 (diff) | |
download | glib-9c32cfbaaa42a89d4d69d62dccd931cf065c53ee.tar.gz |
gfileattribute: Do atomic addition before checking the old value on ref
So we avoid working on a value that is not been updated yet.
-rw-r--r-- | gio/gfileattribute.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/gio/gfileattribute.c b/gio/gfileattribute.c index aa8c61e45..124eb4d07 100644 --- a/gio/gfileattribute.c +++ b/gio/gfileattribute.c @@ -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; } |