Skip to content

Commit 9877bf9

Browse files
committed
crypto: store thread id as pointer-sized value
uv_thread_t is a HANDLE (void pointer) on Windows, which means that on 64-bit windows it cannot be stored with CRYPTO_THREADID_set_numeric without potential data loss. PR-URL: nodejs#124 Reviewed-By: Ben Noordhuis <[email protected]>
1 parent 88e07de commit 9877bf9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/node_crypto.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,9 @@ template int SSLWrap<TLSCallbacks>::TLSExtStatusCallback(SSL* s, void* arg);
150150

151151

152152
static void crypto_threadid_cb(CRYPTO_THREADID* tid) {
153-
CRYPTO_THREADID_set_numeric(tid, uv_thread_self());
153+
static_assert(sizeof(uv_thread_t) <= sizeof(void*),
154+
"uv_thread_t does not fit in a pointer");
155+
CRYPTO_THREADID_set_pointer(tid, reinterpret_cast<void*>(uv_thread_self()));
154156
}
155157

156158

0 commit comments

Comments
 (0)