aboutsummaryrefslogtreecommitdiff
path: root/src/pki_crypto.c
diff options
context:
space:
mode:
authorJakub Jelen <jjelen@redhat.com>2017-11-08 15:35:08 +0100
committerAndreas Schneider <asn@cryptomilk.org>2017-11-08 16:21:36 +0100
commitc4ddf62f7e64409af33c851508a7bf6c76065f32 (patch)
tree8e78b6999ae23141051e7f456bfe16c340fd93f0 /src/pki_crypto.c
parent2ec633f33db5060ec087ef6a923dc91795503faa (diff)
downloadlibssh-c4ddf62f7e64409af33c851508a7bf6c76065f32.tar.gz
libssh-c4ddf62f7e64409af33c851508a7bf6c76065f32.tar.xz
libssh-c4ddf62f7e64409af33c851508a7bf6c76065f32.zip
pki_crypto: Avoid potential memory leak
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'src/pki_crypto.c')
-rw-r--r--src/pki_crypto.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/pki_crypto.c b/src/pki_crypto.c
index 2a8e46ec..e34f197f 100644
--- a/src/pki_crypto.c
+++ b/src/pki_crypto.c
@@ -455,7 +455,7 @@ int pki_key_generate_dss(ssh_key key, int parameter){
int rc;
#if OPENSSL_VERSION_NUMBER > 0x10100000L
key->dsa = DSA_new();
- if (!key->dsa) {
+ if (key->dsa == NULL) {
return SSH_ERROR;
}
rc = DSA_generate_parameters_ex(key->dsa,
@@ -466,6 +466,8 @@ int pki_key_generate_dss(ssh_key key, int parameter){
NULL, /* h_ret */
NULL); /* cb */
if (rc != 1) {
+ DSA_free(key->dsa);
+ key->dsa = NULL;
return SSH_ERROR;
}
#else