diff options
author | LemonBoy <thatlemon@gmail.com> | 2018-09-27 17:23:55 +0200 |
---|---|---|
committer | LemonBoy <thatlemon@gmail.com> | 2018-09-27 17:23:55 +0200 |
commit | 907969d69b5a268a75b77db369a7e36608f6736b (patch) | |
tree | e3db0debbc3daf2fceb8a11e71b73e48e2917c3c /lib | |
parent | 72e15ff739cc73fbf6e3090756d3f9cb3d5af2fa (diff) | |
download | Nim-907969d69b5a268a75b77db369a7e36608f6736b.tar.gz |
Allocate OpenSSL memory outside of the thread heap
Prevent spurious segfaults when OpenSSL is used in multithreaded environments since the library isn't able to handle thread-local memory. Fixes #9016
Diffstat (limited to 'lib')
-rw-r--r-- | lib/wrappers/openssl.nim | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/wrappers/openssl.nim b/lib/wrappers/openssl.nim index 47fff8397..e1d36e461 100644 --- a/lib/wrappers/openssl.nim +++ b/lib/wrappers/openssl.nim @@ -399,14 +399,14 @@ when not useWinVersion and not defined(macosx) and not defined(android) and not proc CRYPTO_set_mem_functions(a,b,c: pointer){.cdecl, dynlib: DLLUtilName, importc.} - proc allocWrapper(size: int): pointer {.cdecl.} = alloc(size) + proc allocWrapper(size: int): pointer {.cdecl.} = allocShared(size) proc reallocWrapper(p: pointer; newsize: int): pointer {.cdecl.} = if p == nil: - if newSize > 0: result = alloc(newsize) - elif newsize == 0: dealloc(p) - else: result = realloc(p, newsize) + if newSize > 0: result = allocShared(newsize) + elif newsize == 0: deallocShared(p) + else: result = reallocShared(p, newsize) proc deallocWrapper(p: pointer) {.cdecl.} = - if p != nil: dealloc(p) + if p != nil: deallocShared(p) proc CRYPTO_malloc_init*() = when not useWinVersion and not defined(macosx) and not defined(android) and not defined(nimNoAllocForSSL): |