diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2011-09-07 17:51:43 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2011-09-07 17:51:43 +0200 |
commit | 6d3d5a446e6791fd2f102b4ae8774e8df2622dc7 (patch) | |
tree | 69038357d0b076cf49ba87368b7b565c5489713d | |
parent | 11f3b0e684793740d180cfc5a19f45783c174219 (diff) | |
download | libssh-6d3d5a446e6791fd2f102b4ae8774e8df2622dc7.tar.gz libssh-6d3d5a446e6791fd2f102b4ae8774e8df2622dc7.tar.xz libssh-6d3d5a446e6791fd2f102b4ae8774e8df2622dc7.zip |
known_hosts: Fix a memleak.
-rw-r--r-- | src/known_hosts.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/known_hosts.c b/src/known_hosts.c index 3f7935e6..4200730f 100644 --- a/src/known_hosts.c +++ b/src/known_hosts.c @@ -613,13 +613,15 @@ int ssh_write_knownhost(ssh_session session) { /* openssh uses a different format for ssh-rsa1 keys. Be compatible --kv */ rc = ssh_pki_export_pubkey_rsa1(key, host, buffer, sizeof(buffer)); + ssh_key_free(key); + SAFE_FREE(host); if (rc < 0) { fclose(file); - SAFE_FREE(host); return -1; } } else { rc = ssh_pki_export_pubkey_base64(key, &b64_key); + ssh_key_free(key); if (rc < 0) { fclose(file); SAFE_FREE(host); @@ -632,9 +634,9 @@ int ssh_write_knownhost(ssh_session session) { key->type_c, b64_key); + SAFE_FREE(host); SAFE_FREE(b64_key); } - SAFE_FREE(host); if (fwrite(buffer, strlen(buffer), 1, file) != 1 || ferror(file)) { fclose(file); |