diff --git a/src/libnm-glib-aux/nm-ref-string.h b/src/libnm-glib-aux/nm-ref-string.h index c7cfe87fd0..45313b394e 100644 --- a/src/libnm-glib-aux/nm-ref-string.h +++ b/src/libnm-glib-aux/nm-ref-string.h @@ -83,7 +83,8 @@ nm_ref_string_unref(NMRefString *rstr) /* fast-path: first try to decrement the ref-count without bringing it * to zero. */ - r = rstr->_ref_count; + r = g_atomic_int_get(&rstr->_ref_count); + if (G_LIKELY(r > 1 && g_atomic_int_compare_and_exchange(&rstr->_ref_count, r, r - 1))) return;