diff options
author | Thomas Haller <thaller@redhat.com> | 2021-06-30 23:19:44 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2021-07-05 15:10:42 +0200 |
commit | 3de83dd25c96e41156194805f45677a59c280c81 (patch) | |
tree | 97eb7e15c54d36d5b4c6d0ef238dcba628838c80 | |
parent | 724ef83e062ccceda4b7f41ce386850982a4fe8a (diff) | |
download | NetworkManager-3de83dd25c96e41156194805f45677a59c280c81.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)
-rw-r--r-- | src/libnm-glib-aux/nm-random-utils.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/libnm-glib-aux/nm-random-utils.c b/src/libnm-glib-aux/nm-random-utils.c index 56b99d5e3c..b6f76b05a9 100644 --- a/src/libnm-glib-aux/nm-random-utils.c +++ b/src/libnm-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; |