diff options
author | Hans Nilsson <[email protected]> | 2019-03-27 16:42:54 +0100 |
---|---|---|
committer | Hans Nilsson <[email protected]> | 2019-04-05 12:41:56 +0200 |
commit | 4334d5c6107d6b6380b61e9200471c28d6c63110 (patch) | |
tree | 294bda157a0c30d5655c1cab951b7d13b5021608 /lib | |
parent | 6b8d1140d74a625ee0b629c924700ab190fe9f1a (diff) | |
download | otp-4334d5c6107d6b6380b61e9200471c28d6c63110.tar.gz otp-4334d5c6107d6b6380b61e9200471c28d6c63110.tar.bz2 otp-4334d5c6107d6b6380b61e9200471c28d6c63110.zip |
crypto: Fix valgrind error for api_ng.c
Diffstat (limited to 'lib')
-rw-r--r-- | lib/crypto/c_src/api_ng.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/crypto/c_src/api_ng.c b/lib/crypto/c_src/api_ng.c index 201c14dfba..107723d2cb 100644 --- a/lib/crypto/c_src/api_ng.c +++ b/lib/crypto/c_src/api_ng.c @@ -420,13 +420,15 @@ int EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, const EVP_CIPHER_CTX *in) ERL_NIF_TERM ng_crypto_update(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) {/* (Context, Data [, IV]) */ struct evp_cipher_ctx *ctx_res; + struct evp_cipher_ctx ctx_res_copy; ERL_NIF_TERM ret; + ctx_res_copy.ctx = NULL; + if (!enif_get_resource(env, argv[0], (ErlNifResourceType*)evp_cipher_ctx_rtype, (void**)&ctx_res)) return EXCP_BADARG(env, "Bad 1:st arg"); if (argc == 3) { - struct evp_cipher_ctx ctx_res_copy; ErlNifBinary ivec_bin; memcpy(&ctx_res_copy, ctx_res, sizeof ctx_res_copy); @@ -481,6 +483,9 @@ ERL_NIF_TERM ng_crypto_update(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[ get_update_args(env, ctx_res, argv[1], &ret); err: + if (ctx_res_copy.ctx) + EVP_CIPHER_CTX_free(ctx_res_copy.ctx); + return ret; /* Both success and error */ } |