summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2021-06-30 23:18:22 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2021-07-16 18:40:00 +0200
commit41126d256aa1e35cf2631e11d6e9545ba1a9c01e (patch)
tree6c94b202bb5adf41117dc006fb6ba957b483767a
parentcfd37f2758c24de5cc84afa8ee7f9d6183e561e9 (diff)
downloadNetworkManager-41126d256aa1e35cf2631e11d6e9545ba1a9c01e.tar.gz
glib-aux: fix releasing thread-local storage from nm_strerror_native()
The previous implementation was just wrong. Fixes: e1ca3bf7ed40 ('shared: add nm_strerror_native() to replace strerror() and g_strerror()') (cherry picked from commit 5bc39d97834c5ba9d81e6f38e07f19eb4e9fd398) (cherry picked from commit 963c395cc2685bde456208726501d79b08d583ce)
-rw-r--r--shared/nm-glib-aux/nm-errno.c14
1 files changed, 1 insertions, 13 deletions
diff --git a/shared/nm-glib-aux/nm-errno.c b/shared/nm-glib-aux/nm-errno.c
index 668606cacd..c05379ec52 100644
--- a/shared/nm-glib-aux/nm-errno.c
+++ b/shared/nm-glib-aux/nm-errno.c
@@ -7,8 +7,6 @@
#include "nm-errno.h"
-#include <pthread.h>
-
/*****************************************************************************/
static NM_UTILS_LOOKUP_STR_DEFINE(
@@ -162,19 +160,9 @@ nm_strerror_native(int errsv)
buf = buf_static;
if (G_UNLIKELY(!buf)) {
- int errno_saved = errno;
- pthread_key_t key;
-
buf = g_malloc(NM_STRERROR_BUFSIZE);
buf_static = buf;
-
- if (pthread_key_create(&key, g_free) != 0 || pthread_setspecific(key, buf) != 0) {
- /* Failure. We will leak the buffer when the thread exits.
- *
- * Nothing we can do about it really. For Debug builds we fail with an assertion. */
- nm_assert_not_reached();
- }
- errno = errno_saved;
+ nm_utils_thread_local_register_destroy(buf, g_free);
}
return nm_strerror_native_r(errsv, buf, NM_STRERROR_BUFSIZE);