aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Hogan <[email protected]>2019-01-04 00:17:21 -0800
committerDoug Hogan <[email protected]>2019-01-08 01:11:58 -0800
commitb80f8543e2e8c27550341d1c337076d7ce3e4290 (patch)
tree418129a71d981155f7dc5b80fc9a0dc3146ec143
parent202b22f5af173029f4c66a7e77026f0d3f8e8766 (diff)
downloadotp-b80f8543e2e8c27550341d1c337076d7ce3e4290.tar.gz
otp-b80f8543e2e8c27550341d1c337076d7ce3e4290.tar.bz2
otp-b80f8543e2e8c27550341d1c337076d7ce3e4290.zip
Revamp crypto_alloc()
-rw-r--r--lib/crypto/c_src/crypto_callback.c11
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)
{