diff options
author | Doug Hogan <[email protected]> | 2019-01-14 21:44:49 -0800 |
---|---|---|
committer | Doug Hogan <[email protected]> | 2019-01-14 21:45:16 -0800 |
commit | 3b51e7933ba42b3299ba0678ce1b4d8a844064cd (patch) | |
tree | 73c355ace1dd1bac0a6cae54be396e9991acd7c7 /lib/crypto/c_src/aes.c | |
parent | c91aecddbd0b1d0aac889da5cf4f8aed8d75637c (diff) | |
download | otp-3b51e7933ba42b3299ba0678ce1b4d8a844064cd.tar.gz otp-3b51e7933ba42b3299ba0678ce1b4d8a844064cd.tar.bz2 otp-3b51e7933ba42b3299ba0678ce1b4d8a844064cd.zip |
enif_release_resource is not NULL safe
* Add if checks and update coccinelle script.
Diffstat (limited to 'lib/crypto/c_src/aes.c')
-rw-r--r-- | lib/crypto/c_src/aes.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/crypto/c_src/aes.c b/lib/crypto/c_src/aes.c index 94b874298e..205cb8b058 100644 --- a/lib/crypto/c_src/aes.c +++ b/lib/crypto/c_src/aes.c @@ -223,7 +223,8 @@ ERL_NIF_TERM aes_ctr_stream_init(ErlNifEnv* env, int argc, const ERL_NIF_TERM ar ret = enif_make_badarg(env); done: - enif_release_resource(ctx); + if (ctx) + enif_release_resource(ctx); return ret; } @@ -270,7 +271,8 @@ ERL_NIF_TERM aes_ctr_stream_encrypt(ErlNifEnv* env, int argc, const ERL_NIF_TERM ret = enif_make_badarg(env); done: - enif_release_resource(new_ctx); + if (new_ctx) + enif_release_resource(new_ctx); return ret; } |