From 01335ecec6c95042e43729b27694c88cd725c413 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 29 Oct 2019 16:48:20 +0100 Subject: [PATCH] shared: assert in nm_ref_string_unref() for valid NMRefString instance --- shared/nm-glib-aux/nm-ref-string.c | 10 ++++++++-- 1 file 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 f128d5583..0a0b0d3a4 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); }