summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2021-06-30 23:19:44 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2021-07-16 18:40:00 +0200
commitcd619a5c92308c7e4ffbfc07329dd86c5c4694e0 (patch)
treea10e2414d2a30340d967d9fd3ff667c125b07673
parent46e595cb26bb62c43a87b15d9eb30e5e56b17519 (diff)
downloadNetworkManager-cd619a5c92308c7e4ffbfc07329dd86c5c4694e0.tar.gz
glib-aux: fix releasing thead-local GRand instance from nm_utils_random_bytes()
Fixes: b01a453ca298 ('core: add nm_utils_random_bytes() and use getrandom()') (cherry picked from commit c127e1beccfd468b2b2bfcca2e7cb1d952068e17) (cherry picked from commit 3de83dd25c96e41156194805f45677a59c280c81)
-rw-r--r--shared/nm-glib-aux/nm-random-utils.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/shared/nm-glib-aux/nm-random-utils.c b/shared/nm-glib-aux/nm-random-utils.c
index c95d368dd3..97272ca31c 100644
--- a/shared/nm-glib-aux/nm-random-utils.c
+++ b/shared/nm-glib-aux/nm-random-utils.c
@@ -122,8 +122,10 @@ fd_open:
*/
has_high_quality = FALSE;
- if (G_UNLIKELY(!rand))
+ if (G_UNLIKELY(!rand)) {
rand = g_rand_new();
+ nm_utils_thread_local_register_destroy(rand, (GDestroyNotify) g_rand_free);
+ }
nm_assert(n > 0);
i = 0;