From 6a0787a366ea598dff6ae09172b28522456a8606 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Tue, 28 Jan 2014 11:56:59 +0100 Subject: [PATCH] pki_crypto: Fix memory leak with EC_KEY_set_public_key(). BUG: https://red.libssh.org/issues/146 --- src/pki_crypto.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pki_crypto.c b/src/pki_crypto.c index 435a8934..9a7c3e28 100644 --- a/src/pki_crypto.c +++ b/src/pki_crypto.c @@ -200,9 +200,11 @@ int pki_pubkey_build_ecdsa(ssh_key key, int nid, ssh_string e) return -1; } + /* EC_KEY_set_public_key duplicates p */ ok = EC_KEY_set_public_key(key->ecdsa, p); + EC_POINT_free(p); if (!ok) { - EC_POINT_free(p); + return -1; } return 0;