mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-28 16:50:16 +01:00
glib-aux: fix releasing thread-local storage from nm_strerror_native()
The previous implementation was just wrong.
Fixes: e1ca3bf7ed ('shared: add nm_strerror_native() to replace strerror() and g_strerror()')
This commit is contained in:
parent
bec4a40437
commit
5bc39d9783
1 changed files with 1 additions and 13 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue