summaryrefslogtreecommitdiffstats
path: root/src/known_hosts.c
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2014-02-05 08:07:45 +0100
committerAris Adamantiadis <aris@0xbadc0de.be>2014-02-05 08:08:31 +0100
commitdca415a38e571bd4f4f289ad5be3f299903461e9 (patch)
treea5fe8fc80de75b46a3aa3bbc14226c82aa54735a /src/known_hosts.c
parent56f86cd4a1d774353b2095aebfdbdd73fa4276ba (diff)
knownhosts: resolve leaks found by coverity
Diffstat (limited to 'src/known_hosts.c')
-rw-r--r--src/known_hosts.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/known_hosts.c b/src/known_hosts.c
index 21f6cf29..e80697d8 100644
--- a/src/known_hosts.c
+++ b/src/known_hosts.c
@@ -678,24 +678,21 @@ char **ssh_knownhosts_algorithms(ssh_session session) {
}
if (session->opts.host == NULL) {
- return 0;
+ return NULL;
}
host = ssh_lowercase(session->opts.host);
hostport = ssh_hostport(host, session->opts.port);
- if (host == NULL || hostport == NULL) {
+ array = malloc(sizeof(char *) * KNOWNHOSTS_MAXTYPES);
+
+ if (host == NULL || hostport == NULL || array == NULL) {
ssh_set_error_oom(session);
SAFE_FREE(host);
SAFE_FREE(hostport);
+ SAFE_FREE(array);
return NULL;
}
- array = malloc(sizeof(char *) * KNOWNHOSTS_MAXTYPES);
- if (array==NULL){
- ssh_set_error_oom(session);
- return NULL;
- }
-
do {
tokens = ssh_get_knownhost_line(&file,
session->opts.knownhosts, &type);