aboutsummaryrefslogtreecommitdiffstats
path: root/lib/crypto/c_src/crypto.c
diff options
context:
space:
mode:
authorHans Nilsson <[email protected]>2018-09-04 18:57:00 +0200
committerHans Nilsson <[email protected]>2018-09-12 09:57:29 +0200
commit46ddd7939820a48f72aa980ff2a1728cf935d4c3 (patch)
tree033c7e4f1e26caecbe21bd0704883925b868c572 /lib/crypto/c_src/crypto.c
parentb9dfc9f6e728e82e727b9f8920a4f0b85f4b0003 (diff)
downloadotp-46ddd7939820a48f72aa980ff2a1728cf935d4c3.tar.gz
otp-46ddd7939820a48f72aa980ff2a1728cf935d4c3.tar.bz2
otp-46ddd7939820a48f72aa980ff2a1728cf935d4c3.zip
crypto: Fix valgrind error
Diffstat (limited to 'lib/crypto/c_src/crypto.c')
-rw-r--r--lib/crypto/c_src/crypto.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/crypto/c_src/crypto.c b/lib/crypto/c_src/crypto.c
index 550342a88d..c7f36c95f1 100644
--- a/lib/crypto/c_src/crypto.c
+++ b/lib/crypto/c_src/crypto.c
@@ -5203,7 +5203,10 @@ static ERL_NIF_TERM pkey_crypt_nif(ErlNifEnv *env, int argc, const ERL_NIF_TERM
unsigned char *p;
if (rsa == NULL) goto badarg;
tmplen = RSA_size(rsa);
- if (!enif_alloc_binary(tmplen, &tmp_bin)) goto badarg;
+ if (!enif_alloc_binary(tmplen, &tmp_bin)) {
+ RSA_free(rsa);
+ goto badarg;
+ }
p = out_bin.data;
p++;
i = RSA_padding_check_SSLv23(tmp_bin.data, tmplen, p, out_bin.size - 1, tmplen);
@@ -5214,6 +5217,7 @@ static ERL_NIF_TERM pkey_crypt_nif(ErlNifEnv *env, int argc, const ERL_NIF_TERM
tmp_bin = in_bin;
i = 1;
}
+ RSA_free(rsa);
}
#endif
}