Commit d190c275b9 for openssl.org
commit d190c275b9b34baf573a067e31fc0dd727599df7
Author: Jakub Zelenka <jakub.zelenka@openssl.foundation>
Date: Thu Sep 17 12:40:17 2026 +0200
Fix lock_failed output in Windows cmp_exch_ptr
The Windows implementation of CRYPTO_atomic_cmp_exch_ptr() assigned 0
to the lock_failed parameter itself instead of writing through it, so
the caller's flag was never set, contrary to the documented behaviour.
Callers that read the flag after a failed exchange without initializing
it first could act on an indeterminate value.
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.foundation>
Merge-date: Mon Sep 21 09:55:22 2026
Merged-from: https://github.com/openssl/openssl/pull/32867
diff --git a/crypto/threads_win.c b/crypto/threads_win.c
index d777010cd8..dd1e79d3e9 100644
--- a/crypto/threads_win.c
+++ b/crypto/threads_win.c
@@ -781,7 +781,7 @@ int CRYPTO_atomic_cmp_exch_ptr(void **ptr, void **expect, void *desire, CRYPTO_R
void *initial;
if (lock_failed != NULL)
- lock_failed = 0;
+ *lock_failed = 0;
/* Load the current pointer value */
initial = InterlockedCompareExchangePointer(ptr, desire, *expect);