fixes a long standing openssl wrapper bug: pass C compliant allocation functions to CRYPTO_set_mem_functions
This commit is contained in:
parent
a0ad3aa183
commit
cfb76164b8
1 changed files with 10 additions and 1 deletions
|
|
@ -280,9 +280,18 @@ when not useWinVersion:
|
||||||
proc CRYPTO_set_mem_functions(a,b,c: pointer){.cdecl,
|
proc CRYPTO_set_mem_functions(a,b,c: pointer){.cdecl,
|
||||||
dynlib: DLLUtilName, importc.}
|
dynlib: DLLUtilName, importc.}
|
||||||
|
|
||||||
|
proc allocWrapper(size: int): pointer {.cdecl.} = alloc(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)
|
||||||
|
proc deallocWrapper(p: pointer) {.cdecl.} =
|
||||||
|
if p != nil: dealloc(p)
|
||||||
|
|
||||||
proc CRYPTO_malloc_init*() =
|
proc CRYPTO_malloc_init*() =
|
||||||
when not useWinVersion:
|
when not useWinVersion:
|
||||||
CRYPTO_set_mem_functions(alloc, realloc, dealloc)
|
CRYPTO_set_mem_functions(allocWrapper, reallocWrapper, deallocWrapper)
|
||||||
|
|
||||||
proc SSL_CTX_ctrl*(ctx: SslCtx, cmd: cInt, larg: int, parg: pointer): int{.
|
proc SSL_CTX_ctrl*(ctx: SslCtx, cmd: cInt, larg: int, parg: pointer): int{.
|
||||||
cdecl, dynlib: DLLSSLName, importc.}
|
cdecl, dynlib: DLLSSLName, importc.}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue