Skip to content

Commit 6f4d87d

Browse files
qmuntaldagood
andauthored
Use valid address in pthread_setspecific to silence warnings (#162)
* use valid address in pthread_setspecific to silence warnings * Update thread_setup_unix.c Co-authored-by: Davis Goodin <[email protected]> * use local variable instead of global --------- Co-authored-by: Davis Goodin <[email protected]>
1 parent 2ae7b98 commit 6f4d87d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

thread_setup_unix.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@ static void thread_id(GO_CRYPTO_THREADID_PTR tid)
2828
// per-thread error state, so this function is guaranteed to be executed at
2929
// least once on any thread with associated error state. The thread-local
3030
// variable needs to be set to a non-NULL value so that the destructor will
31-
// be called when the thread exits. The actual value does not matter.
32-
(void) pthread_setspecific(destructor_key, (void*)1);
31+
// be called when the thread exits.
32+
// The actual value does not matter, but should be a pointer with a valid size.
33+
// See https://github.com/golang-fips/openssl/pull/162
34+
static char stub;
35+
(void) pthread_setspecific(destructor_key, &stub);
3336
}
3437

3538
static void cleanup_thread_state(void *ignored)

0 commit comments

Comments
 (0)