mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-09 09:54:25 +09:00
Fix memory leaks.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@356 7dcaeef0-15fb-0310-b436-a5af3365683c
This commit is contained in:
@@ -249,9 +249,7 @@ int ssh_options_set_host(SSH_OPTIONS *opt, const char *hostname){
|
|||||||
}
|
}
|
||||||
p = strchr(h, '@');
|
p = strchr(h, '@');
|
||||||
|
|
||||||
if (opt->host) {
|
SAFE_FREE(opt->host);
|
||||||
SAFE_FREE(opt->host);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (p) {
|
if (p) {
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
@@ -261,9 +259,7 @@ int ssh_options_set_host(SSH_OPTIONS *opt, const char *hostname){
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opt->username) {
|
SAFE_FREE(opt->username);
|
||||||
SAFE_FREE(opt->username);
|
|
||||||
}
|
|
||||||
opt->username = strdup(h);
|
opt->username = strdup(h);
|
||||||
SAFE_FREE(h);
|
SAFE_FREE(h);
|
||||||
if (opt->username == NULL) {
|
if (opt->username == NULL) {
|
||||||
@@ -292,10 +288,7 @@ int ssh_options_set_username(SSH_OPTIONS *opt, const char *username) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opt->username) {
|
SAFE_FREE(opt->username);
|
||||||
SAFE_FREE(opt->username);
|
|
||||||
}
|
|
||||||
|
|
||||||
opt->username = strdup(username);
|
opt->username = strdup(username);
|
||||||
if (opt->username == NULL) {
|
if (opt->username == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
@@ -346,6 +339,7 @@ int ssh_options_set_bind(SSH_OPTIONS *opt, const char *bindaddr, int port) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SAFE_FREE(opt->bindaddr);
|
||||||
opt->bindaddr = strdup(bindaddr);
|
opt->bindaddr = strdup(bindaddr);
|
||||||
if (opt->bindaddr == NULL) {
|
if (opt->bindaddr == NULL) {
|
||||||
return -1;
|
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());
|
snprintf(buffer, 1024, dir, ssh_get_user_home_dir());
|
||||||
|
SAFE_FREE(opt->ssh_dir);
|
||||||
opt->ssh_dir = strdup(buffer);
|
opt->ssh_dir = strdup(buffer);
|
||||||
if (opt->ssh_dir == NULL) {
|
if (opt->ssh_dir == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
Reference in New Issue
Block a user