aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorNikola Pajkovsky <[email protected]>2026-09-09 08:10:21 +0200
committerTomas Mraz <[email protected]>2026-09-21 11:35:34 +0200
commitd50111380c22bd7147d7eb92e880b523f28a5a2c (patch)
treef6840f3bcb7f8af55a6b6a5862e940b520426209 /include
parentPoison the ASN1_STRING NUL terminator under Valgrind (diff)
downloadopenssl-d50111380c22bd7147d7eb92e880b523f28a5a2c.tar.gz
openssl-d50111380c22bd7147d7eb92e880b523f28a5a2c.zip
refcount: declare Windows CRYPTO_REF_COUNT as volatile long
_InterlockedExchangeAdd() is prototyped as LONG _InterlockedExchangeAdd(volatile LONG *, LONG) but CRYPTO_REF_COUNT held a volatile int. The MSVC branch passed &refcnt->val straight in, which does not compile: refcount.h(189): note: 'LONG _InterlockedExchangeAdd(volatile LONG *,LONG)': cannot convert argument 1 from 'volatile int *' to 'volatile LONG *' refcount.h(189): note: Types pointed to are unrelated Declare val as volatile long in both the __ICL/_WIN32 and the _MSC_VER variants and drop the cast, so the object type matches what the intrinsic operates on. Fixes: https://github.com/openssl/openssl/issues/21080 Signed-off-by: Nikola Pajkovsky <[email protected]> Reviewed-by: Mounir Idrassi <[email protected]> Reviewed-by: Tom Cosgrove <[email protected]> Merge-date: Mon Sep 21 09:35:35 2026 Merged-from: https://github.com/openssl/openssl/pull/32754
Diffstat (limited to 'include')
-rw-r--r--include/internal/refcount.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/include/internal/refcount.h b/include/internal/refcount.h
index 149a3fd59e5..7cc4ce660e1 100644
--- a/include/internal/refcount.h
+++ b/include/internal/refcount.h
@@ -93,21 +93,22 @@ static __inline__ int CRYPTO_DOWN_REF(CRYPTO_REF_COUNT *refcnt, int *ret)
}
#elif defined(__ICL) && defined(_WIN32)
+#include <intrin.h>
#define HAVE_ATOMICS 1
typedef struct {
- volatile int val;
+ volatile long val;
} CRYPTO_REF_COUNT;
static __inline bool CRYPTO_UP_REF(CRYPTO_REF_COUNT *refcnt, int *ret)
{
- *ret = _InterlockedExchangeAdd((void *)&refcnt->val, 1) + 1;
+ *ret = _InterlockedExchangeAdd(&refcnt->val, 1) + 1;
return true;
}
static __inline int CRYPTO_DOWN_REF(CRYPTO_REF_COUNT *refcnt, int *ret)
{
- *ret = _InterlockedExchangeAdd((void *)&refcnt->val, -1) - 1;
+ *ret = _InterlockedExchangeAdd(&refcnt->val, -1) - 1;
return 1;
}
@@ -116,7 +117,7 @@ static __inline int CRYPTO_DOWN_REF(CRYPTO_REF_COUNT *refcnt, int *ret)
#define HAVE_ATOMICS 1
typedef struct {
- volatile int val;
+ volatile long val;
} CRYPTO_REF_COUNT;
#if (defined(_M_ARM) && _M_ARM >= 7) || defined(_M_ARM64)