diff options
author | Andreas Schneider <mail@cynapses.org> | 2009-04-02 12:07:06 +0000 |
---|---|---|
committer | Andreas Schneider <mail@cynapses.org> | 2009-04-02 12:07:06 +0000 |
commit | 4d203e8420b0be0a3cd327f0ab9dc688fed54026 (patch) | |
tree | c183617765ad42dc82ce5899e41db34fc2ac897d /libssh/options.c | |
parent | 5ba2acde0aa899db94cdf18bf0a0d32071e58405 (diff) | |
download | libssh-4d203e8420b0be0a3cd327f0ab9dc688fed54026.tar.gz libssh-4d203e8420b0be0a3cd327f0ab9dc688fed54026.tar.xz libssh-4d203e8420b0be0a3cd327f0ab9dc688fed54026.zip |
Fix memory leaks.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@356 7dcaeef0-15fb-0310-b436-a5af3365683c
Diffstat (limited to 'libssh/options.c')
-rw-r--r-- | libssh/options.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/libssh/options.c b/libssh/options.c index fca875e8..71dc7496 100644 --- a/libssh/options.c +++ b/libssh/options.c @@ -249,9 +249,7 @@ int ssh_options_set_host(SSH_OPTIONS *opt, const char *hostname){ } p = strchr(h, '@'); - if (opt->host) { - SAFE_FREE(opt->host); - } + SAFE_FREE(opt->host); if (p) { *p = '\0'; @@ -261,9 +259,7 @@ int ssh_options_set_host(SSH_OPTIONS *opt, const char *hostname){ return -1; } - if (opt->username) { - SAFE_FREE(opt->username); - } + SAFE_FREE(opt->username); opt->username = strdup(h); SAFE_FREE(h); if (opt->username == NULL) { @@ -292,10 +288,7 @@ int ssh_options_set_username(SSH_OPTIONS *opt, const char *username) { return -1; } - if (opt->username) { - SAFE_FREE(opt->username); - } - + SAFE_FREE(opt->username); opt->username = strdup(username); if (opt->username == NULL) { return -1; @@ -346,6 +339,7 @@ int ssh_options_set_bind(SSH_OPTIONS *opt, const char *bindaddr, int port) { return -1; } + SAFE_FREE(opt->bindaddr); opt->bindaddr = strdup(bindaddr); if (opt->bindaddr == NULL) { return -1; @@ -378,6 +372,7 @@ int ssh_options_set_ssh_dir(SSH_OPTIONS *opt, const char *dir) { } snprintf(buffer, 1024, dir, ssh_get_user_home_dir()); + SAFE_FREE(opt->ssh_dir); opt->ssh_dir = strdup(buffer); if (opt->ssh_dir == NULL) { return -1; |