From 135fa8dbe3d66b5186217f5d8cd6dbac4c94ec4c Mon Sep 17 00:00:00 2001 From: Georgi Valkov Date: Tue, 3 Sep 2024 10:13:34 +0300 Subject: [PATCH] threads_win: fix improper cast to long * instead of LONG * InterlockedExchangeAdd expects arguments of type LONG *, LONG but the int arguments were improperly cast to long *, long Note: - LONG is always 32 bit - long is 32 bit on Win32 VC x86/x64 and MingW-W64 - long is 64 bit on cygwin64 Signed-off-by: Georgi Valkov Reviewed-by: Tom Cosgrove Reviewed-by: Neil Horman Reviewed-by: Richard Levitte Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/25360) (cherry picked from commit b0ed90cc30a573acb9b27186babc616be482afcb) --- crypto/threads_win.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crypto/threads_win.c b/crypto/threads_win.c index dbeda74d73a..43f36ee6a33 100644 --- a/crypto/threads_win.c +++ b/crypto/threads_win.c @@ -212,7 +212,8 @@ int CRYPTO_THREAD_compare_id(CRYPTO_THREAD_ID a, CRYPTO_THREAD_ID b) int CRYPTO_atomic_add(int *val, int amount, int *ret, CRYPTO_RWLOCK *lock) { - *ret = (int)InterlockedExchangeAdd((long volatile *)val, (long)amount) + amount; + *ret = (int)InterlockedExchangeAdd((LONG volatile *)val, (LONG)amount) + + amount; return 1; } -- 2.47.2