From c127e1beccfd468b2b2bfcca2e7cb1d952068e17 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 30 Jun 2021 23:19:44 +0200 Subject: [PATCH] glib-aux: fix releasing thead-local GRand instance from nm_utils_random_bytes() Fixes: b01a453ca298 ('core: add nm_utils_random_bytes() and use getrandom()') --- src/libnm-glib-aux/nm-random-utils.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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;