aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <mail@cynapses.org>2009-04-17 14:53:24 +0000
committerAndreas Schneider <mail@cynapses.org>2009-04-17 14:53:24 +0000
commit44ab293f0b7d52de26380df9ec2ac88806d6aeff (patch)
treea8e972b3e171f876f1f3a8dbf32880b933c40646
parentbf4d29b96399f5b1ed8927156b746d8d2f647ba2 (diff)
downloadlibssh-44ab293f0b7d52de26380df9ec2ac88806d6aeff.tar.gz
libssh-44ab293f0b7d52de26380df9ec2ac88806d6aeff.tar.xz
libssh-44ab293f0b7d52de26380df9ec2ac88806d6aeff.zip
Don't leak memory.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@527 7dcaeef0-15fb-0310-b436-a5af3365683c
-rw-r--r--libssh/keys.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/libssh/keys.c b/libssh/keys.c
index 04ddcd09..c4b47f4d 100644
--- a/libssh/keys.c
+++ b/libssh/keys.c
@@ -248,6 +248,7 @@ void publickey_free(PUBLIC_KEY *key) {
}
PUBLIC_KEY *publickey_from_string(SSH_SESSION *session, STRING *pubkey_s) {
+ PUBLIC_KEY *key = NULL;
BUFFER *tmpbuf = NULL;
STRING *type_s = NULL;
char *type = NULL;
@@ -276,15 +277,21 @@ PUBLIC_KEY *publickey_from_string(SSH_SESSION *session, STRING *pubkey_s) {
if(strcmp(type, "ssh-dss") == 0) {
SAFE_FREE(type);
- return publickey_make_dss(session, tmpbuf);
+ key = publickey_make_dss(session, tmpbuf);
+ buffer_free(tmpbuf);
+ return key;
}
if(strcmp(type,"ssh-rsa") == 0) {
SAFE_FREE(type);
- return publickey_make_rsa(session, tmpbuf,"ssh-rsa");
+ key = publickey_make_rsa(session, tmpbuf,"ssh-rsa");
+ buffer_free(tmpbuf);
+ return key;
}
if (strcmp(type,"ssh-rsa1") == 0) {
SAFE_FREE(type);
- return publickey_make_rsa(session, tmpbuf,"ssh-rsa1");
+ key = publickey_make_rsa(session, tmpbuf,"ssh-rsa1");
+ buffer_free(tmpbuf);
+ return key;
}
ssh_set_error(session, SSH_FATAL, "Unknown public key protocol %s", type);