From 1de6818a30fa11350460aa148e1ee30cad0a9b10 Mon Sep 17 00:00:00 2001 From: Andy Polyakov Date: Fri, 20 Jul 2018 13:19:11 +0200 Subject: [PATCH] crypto/cryptlib.c: resolve possible race in OPENSSL_isservice. Reviewed-by: Kurt Roeckx (Merged from https://github.com/openssl/openssl/pull/6752) (cherry picked from commit 9e4a1c3f65863b0175ddc534e232e63c4f82ea5c) --- crypto/cryptlib.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/crypto/cryptlib.c b/crypto/cryptlib.c index d93bcd357b..bf73244394 100644 --- a/crypto/cryptlib.c +++ b/crypto/cryptlib.c @@ -128,10 +128,14 @@ int OPENSSL_isservice(void) if (_OPENSSL_isservice.p == NULL) { HANDLE mod = GetModuleHandle(NULL); + FARPROC f; + if (mod != NULL) - _OPENSSL_isservice.f = GetProcAddress(mod, "_OPENSSL_isservice"); - if (_OPENSSL_isservice.p == NULL) + f = GetProcAddress(mod, "_OPENSSL_isservice"); + if (f == NULL) _OPENSSL_isservice.p = (void *)-1; + else + _OPENSSL_isservice.f = f; } if (_OPENSSL_isservice.p != (void *)-1) -- 2.25.1