mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-28 06:20:10 +01:00
glib-aux/tests: avoid coverity warning in test_nm_g_source_sentinel()
Coverity wrongly think there is a use after free in the test:
Error: USE_AFTER_FREE (CWE-416): [#def559] [important]
NetworkManager-1.31.90/src/libnm-glib-aux/tests/test-shared-general.c:1305: alias: Assigning: "s1" = "_s". Now both point to the same storage.
NetworkManager-1.31.90/src/libnm-glib-aux/tests/test-shared-general.c:1324: freed_arg: "g_source_unref" frees "s1".
NetworkManager-1.31.90/src/libnm-glib-aux/tests/test-shared-general.c:1330: deref_after_free: Dereferencing freed pointer "s1".
# 1328| s2 = nm_g_source_sentinel_get(0);
# 1329| g_assert(s2 == s1);
# 1330|-> g_assert_cmpint(g_atomic_int_get(&s1->ref_count), >=, 1);
# 1331| }
# 1332| }
Rework the code in the hope to avoid the false warning.
This commit is contained in:
parent
c87433ebd2
commit
7825609f1f
1 changed files with 1 additions and 1 deletions
|
|
@ -1326,8 +1326,8 @@ test_nm_g_source_sentinel(void)
|
|||
|
||||
if (nmtst_get_rand_bool()) {
|
||||
s2 = nm_g_source_sentinel_get(0);
|
||||
g_assert_cmpint(g_atomic_int_get(&s2->ref_count), >=, 1);
|
||||
g_assert(s2 == s1);
|
||||
g_assert_cmpint(g_atomic_int_get(&s1->ref_count), >=, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue