diff options
author | Doug Hogan <[email protected]> | 2019-01-04 00:20:15 -0800 |
---|---|---|
committer | Doug Hogan <[email protected]> | 2019-01-08 01:11:58 -0800 |
commit | c1c98585b05f82a41d81aa24b20936be931a7082 (patch) | |
tree | 15a56a58ad0ef8b0e524a1f0ffeb5afb8b336a65 | |
parent | b80f8543e2e8c27550341d1c337076d7ce3e4290 (diff) | |
download | otp-c1c98585b05f82a41d81aa24b20936be931a7082.tar.gz otp-c1c98585b05f82a41d81aa24b20936be931a7082.tar.bz2 otp-c1c98585b05f82a41d81aa24b20936be931a7082.zip |
Revamp crypto_realloc()
-rw-r--r-- | lib/crypto/c_src/crypto_callback.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/crypto/c_src/crypto_callback.c b/lib/crypto/c_src/crypto_callback.c index ae14e5768c..dda8b32deb 100644 --- a/lib/crypto/c_src/crypto_callback.c +++ b/lib/crypto/c_src/crypto_callback.c @@ -77,12 +77,18 @@ static void* crypto_alloc(size_t size CCB_FILE_LINE_ARGS) } static void* crypto_realloc(void* ptr, size_t size CCB_FILE_LINE_ARGS) { - void* ret = enif_realloc(ptr, size); + void* ret; - if (!ret && size) - nomem(size, "reallocate"); + if ((ret = enif_realloc(ptr, size)) == NULL) + goto err; return ret; + + err: + if (size) + nomem(size, "reallocate"); + return NULL; } + static void crypto_free(void* ptr CCB_FILE_LINE_ARGS) { enif_free(ptr); |