summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2019-10-29 16:48:20 +0100
committerThomas Haller <thaller@redhat.com>2019-11-07 11:34:36 +0100
commit01335ecec6c95042e43729b27694c88cd725c413 (patch)
tree5cc2e4c3e6b2ede1ade20e8c5eaefc973f9d1ef7
parent15fe8ad85126eeab2bf92ffbdd7258947dcd67c0 (diff)
downloadNetworkManager-01335ecec6c95042e43729b27694c88cd725c413.tar.gz
shared: assert in nm_ref_string_unref() for valid NMRefString instance
-rw-r--r--shared/nm-glib-aux/nm-ref-string.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/shared/nm-glib-aux/nm-ref-string.c b/shared/nm-glib-aux/nm-ref-string.c
index f128d55832..0a0b0d3a41 100644
--- a/shared/nm-glib-aux/nm-ref-string.c
+++ b/shared/nm-glib-aux/nm-ref-string.c
@@ -180,8 +180,14 @@ _nm_ref_string_unref_non_null (NMRefString *rstr)
/* in the fast-path above, we already decremented the ref-count to zero.
* We need recheck that the ref-count is still zero. */
- if (g_atomic_int_get (&rstr0->ref_count) == 0)
- g_hash_table_remove (gl_hash, rstr0);
+ if (g_atomic_int_get (&rstr0->ref_count) == 0) {
+ if (!g_hash_table_remove (gl_hash, rstr0))
+ nm_assert_not_reached ();
+ } else {
+#if NM_MORE_ASSERTS > 5
+ nm_assert (g_hash_table_lookup (gl_hash, rstr0) == rstr0);
+#endif
+ }
G_UNLOCK (gl_lock);
}