summaryrefslogtreecommitdiffstats
path: root/libssh/kex.c
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2010-04-28 18:43:41 +0200
committerAris Adamantiadis <aris@0xbadc0de.be>2010-04-28 18:43:41 +0200
commit20e7ec96ae01d4367a7fbcd87bdbf0fa6496492b (patch)
treee2c7e9e7bda246d0b376ffeb3d19252b6f3f1c5e /libssh/kex.c
parent2e563e0fa88aa174d3b945202fbe8f81a81bd4c3 (diff)
downloadlibssh-20e7ec96ae01d4367a7fbcd87bdbf0fa6496492b.tar.gz
libssh-20e7ec96ae01d4367a7fbcd87bdbf0fa6496492b.tar.xz
libssh-20e7ec96ae01d4367a7fbcd87bdbf0fa6496492b.zip
Fix bugs found by clang analyzer
Diffstat (limited to 'libssh/kex.c')
-rw-r--r--libssh/kex.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/libssh/kex.c b/libssh/kex.c
index a411755b..ca678947 100644
--- a/libssh/kex.c
+++ b/libssh/kex.c
@@ -202,7 +202,7 @@ char **space_tokenize(const char *chain){
/* find_matching gets 2 parameters : a list of available objects (available_d), separated by colons,*/
/* and a list of preferred objects (preferred_d) */
-/* it will return a strduped pointer on the first prefered object found in the available objects list */
+/* it will return a strduped pointer on the first preferred object found in the available objects list */
char *ssh_find_matching(const char *available_d, const char *preferred_d){
char ** tok_available, **tok_preferred;
@@ -222,6 +222,7 @@ char *ssh_find_matching(const char *available_d, const char *preferred_d){
if (tok_preferred == NULL) {
SAFE_FREE(tok_available[0]);
SAFE_FREE(tok_available);
+ return NULL;
}
for(i_pref=0; tok_preferred[i_pref] ; ++i_pref){
@@ -230,18 +231,18 @@ char *ssh_find_matching(const char *available_d, const char *preferred_d){
/* match */
ret=strdup(tok_available[i_avail]);
/* free the tokens */
- free(tok_available[0]);
- free(tok_preferred[0]);
- free(tok_available);
- free(tok_preferred);
+ SAFE_FREE(tok_available[0]);
+ SAFE_FREE(tok_preferred[0]);
+ SAFE_FREE(tok_available);
+ SAFE_FREE(tok_preferred);
return ret;
}
}
}
- free(tok_available[0]);
- free(tok_preferred[0]);
- free(tok_available);
- free(tok_preferred);
+ SAFE_FREE(tok_available[0]);
+ SAFE_FREE(tok_preferred[0]);
+ SAFE_FREE(tok_available);
+ SAFE_FREE(tok_preferred);
return NULL;
}