diff options
author | Doug Hogan <[email protected]> | 2019-01-04 00:17:21 -0800 |
---|---|---|
committer | Doug Hogan <[email protected]> | 2019-01-08 01:11:58 -0800 |
commit | b80f8543e2e8c27550341d1c337076d7ce3e4290 (patch) | |
tree | 418129a71d981155f7dc5b80fc9a0dc3146ec143 /lib/crypto/c_src | |
parent | 202b22f5af173029f4c66a7e77026f0d3f8e8766 (diff) | |
download | otp-b80f8543e2e8c27550341d1c337076d7ce3e4290.tar.gz otp-b80f8543e2e8c27550341d1c337076d7ce3e4290.tar.bz2 otp-b80f8543e2e8c27550341d1c337076d7ce3e4290.zip |
Revamp crypto_alloc()
Diffstat (limited to 'lib/crypto/c_src')
-rw-r--r-- | lib/crypto/c_src/crypto_callback.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/crypto/c_src/crypto_callback.c b/lib/crypto/c_src/crypto_callback.c index 0cc7dd609d..ae14e5768c 100644 --- a/lib/crypto/c_src/crypto_callback.c +++ b/lib/crypto/c_src/crypto_callback.c @@ -64,11 +64,16 @@ static void nomem(size_t size, const char* op) static void* crypto_alloc(size_t size CCB_FILE_LINE_ARGS) { - void *ret = enif_alloc(size); + void *ret; - if (!ret && size) - nomem(size, "allocate"); + if ((ret = enif_alloc(size)) == NULL) + goto err; return ret; + + err: + if (size) + nomem(size, "allocate"); + return NULL; } static void* crypto_realloc(void* ptr, size_t size CCB_FILE_LINE_ARGS) { |