aboutsummaryrefslogtreecommitdiff
path: root/crypto/compat/crypto_lock_win.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/compat/crypto_lock_win.c')
-rw-r--r--crypto/compat/crypto_lock_win.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/crypto/compat/crypto_lock_win.c b/crypto/compat/crypto_lock_win.c
index e995726..b3b1858 100644
--- a/crypto/compat/crypto_lock_win.c
+++ b/crypto/compat/crypto_lock_win.c
@@ -1,6 +1,7 @@
1/* $OpenBSD: crypto_lock.c,v 1.1 2018/11/11 06:41:28 bcook Exp $ */ 1/* $OpenBSD: crypto_lock.c,v 1.1 2018/11/11 06:41:28 bcook Exp $ */
2/* 2/*
3 * Copyright (c) 2018 Brent Cook <bcook@openbsd.org> 3 * Copyright (c) 2019 Brent Cook <bcook@openbsd.org>
4 * Copyright (c) 2019 John Norrbin <jlnorrbin@johnex.se>
4 * 5 *
5 * Permission to use, copy, modify, and distribute this software for any 6 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above 7 * purpose with or without fee is hereby granted, provided that the above
@@ -29,8 +30,9 @@ CRYPTO_lock(int mode, int type, const char *file, int line)
29 30
30 if (locks[type] == NULL) { 31 if (locks[type] == NULL) {
31 LPCRITICAL_SECTION lcs = malloc(sizeof(CRITICAL_SECTION)); 32 LPCRITICAL_SECTION lcs = malloc(sizeof(CRITICAL_SECTION));
33 if (lcs == NULL) exit(ENOMEM);
32 InitializeCriticalSection(lcs); 34 InitializeCriticalSection(lcs);
33 if (InterlockedCompareExchangePointer((void **)&locks[type], (void *)lcs, NULL) != NULL) { 35 if (InterlockedCompareExchangePointer((PVOID*)&locks[type], (PVOID)lcs, NULL) != NULL) {
34 DeleteCriticalSection(lcs); 36 DeleteCriticalSection(lcs);
35 free(lcs); 37 free(lcs);
36 } 38 }