diff options
author | Hans Nilsson <[email protected]> | 2019-06-26 16:24:26 +0200 |
---|---|---|
committer | Hans Nilsson <[email protected]> | 2019-06-26 16:24:26 +0200 |
commit | 9a47f8f0bfd4e10b73215f92838427e10bb2861e (patch) | |
tree | 88f16f8effdac8249b9054f38e4c50a5cd9389ae /lib/crypto | |
parent | e2e16a9fdb99788e77ab12c1834cc819eed49a0c (diff) | |
parent | 4209eff3287373c4c6fd67e9e30507a13ebf7555 (diff) | |
download | otp-9a47f8f0bfd4e10b73215f92838427e10bb2861e.tar.gz otp-9a47f8f0bfd4e10b73215f92838427e10bb2861e.tar.bz2 otp-9a47f8f0bfd4e10b73215f92838427e10bb2861e.zip |
Merge branch 'maint'
* maint:
crypto: Adjust VALGRIND decls
crypto: Fix mem leak detected by valgrind
Diffstat (limited to 'lib/crypto')
-rw-r--r-- | lib/crypto/c_src/api_ng.c | 7 | ||||
-rw-r--r-- | lib/crypto/c_src/bn.c | 7 |
2 files changed, 3 insertions, 11 deletions
diff --git a/lib/crypto/c_src/api_ng.c b/lib/crypto/c_src/api_ng.c index a109f444cf..941e03cc98 100644 --- a/lib/crypto/c_src/api_ng.c +++ b/lib/crypto/c_src/api_ng.c @@ -334,12 +334,11 @@ ERL_NIF_TERM ng_crypto_init_nif(ErlNifEnv* env, int argc, const ERL_NIF_TERM arg if ((ctx_res = enif_alloc_resource(evp_cipher_ctx_rtype, sizeof(struct evp_cipher_ctx))) == NULL) return EXCP_ERROR(env, "Can't allocate resource"); - if (!get_init_args(env, ctx_res, argv[0], argv[1], argv[2], argv[argc-1], + if (get_init_args(env, ctx_res, argv[0], argv[1], argv[2], argv[argc-1], &cipherp, &ret)) - /* Error msg in &ret */ - goto ret; + ret = enif_make_resource(env, ctx_res); + /* else error msg in ret */ - ret = enif_make_resource(env, ctx_res); if(ctx_res) enif_release_resource(ctx_res); } else if (enif_get_resource(env, argv[0], (ErlNifResourceType*)evp_cipher_ctx_rtype, (void**)&ctx_res)) { diff --git a/lib/crypto/c_src/bn.c b/lib/crypto/c_src/bn.c index 34ed4f7ebc..6021d56db6 100644 --- a/lib/crypto/c_src/bn.c +++ b/lib/crypto/c_src/bn.c @@ -32,8 +32,6 @@ int get_bn_from_mpint(ErlNifEnv* env, ERL_NIF_TERM term, BIGNUM** bnp) if (bin.size > INT_MAX - 4) goto err; - ERL_VALGRIND_ASSERT_MEM_DEFINED(bin.data, bin.size); - if (bin.size < 4) goto err; sz = (int)bin.size - 4; @@ -60,8 +58,6 @@ int get_bn_from_bin(ErlNifEnv* env, ERL_NIF_TERM term, BIGNUM** bnp) if (bin.size > INT_MAX) goto err; - ERL_VALGRIND_ASSERT_MEM_DEFINED(bin.data, bin.size); - if ((ret = BN_bin2bn(bin.data, (int)bin.size, NULL)) == NULL) goto err; @@ -103,8 +99,6 @@ ERL_NIF_TERM mod_exp_nif(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) unsigned extra_byte; ERL_NIF_TERM ret; - ASSERT(argc == 4); - if (!get_bn_from_bin(env, argv[0], &bn_base)) goto bad_arg; if (!get_bn_from_bin(env, argv[1], &bn_exponent)) @@ -177,7 +171,6 @@ ERL_NIF_TERM bn2term(ErlNifEnv* env, const BIGNUM *bn) BN_bn2bin(bn, ptr); - ERL_VALGRIND_MAKE_MEM_DEFINED(ptr, dlen); return ret; err: |