summary refs log tree commit diff
path: root/shared/nm-glib-aux/nm-random-utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'shared/nm-glib-aux/nm-random-utils.c')
-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 c95d368d..97272ca3 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;