1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-12-02 01:17:52 +03:00

Fix memory leaks in ssh_bind_options_set() if called twice.

This fixes ticket #36.
This commit is contained in:
Andreas Schneider
2009-10-22 18:56:02 +02:00
parent 27d25752e9
commit 840cecbe0e

View File

@@ -684,6 +684,7 @@ int ssh_bind_options_set(ssh_bind sshbind, enum ssh_bind_options_e type,
ssh_set_error_invalid(sshbind, __FUNCTION__); ssh_set_error_invalid(sshbind, __FUNCTION__);
return -1; return -1;
} else { } else {
SAFE_FREE(sshbind->bindaddr);
sshbind->bindaddr = strdup(value); sshbind->bindaddr = strdup(value);
if (sshbind->bindaddr == NULL) { if (sshbind->bindaddr == NULL) {
ssh_set_error_oom(sshbind); ssh_set_error_oom(sshbind);
@@ -762,6 +763,7 @@ int ssh_bind_options_set(ssh_bind sshbind, enum ssh_bind_options_e type,
ssh_set_error_invalid(sshbind, __FUNCTION__); ssh_set_error_invalid(sshbind, __FUNCTION__);
return -1; return -1;
} else { } else {
SAFE_FREE(sshbind->rsakey);
sshbind->rsakey = strdup(value); sshbind->rsakey = strdup(value);
if (sshbind->rsakey == NULL) { if (sshbind->rsakey == NULL) {
ssh_set_error_oom(sshbind); ssh_set_error_oom(sshbind);
@@ -774,6 +776,7 @@ int ssh_bind_options_set(ssh_bind sshbind, enum ssh_bind_options_e type,
ssh_set_error_invalid(sshbind, __FUNCTION__); ssh_set_error_invalid(sshbind, __FUNCTION__);
return -1; return -1;
} else { } else {
SAFE_FREE(sshbind->banner);
sshbind->banner = strdup(value); sshbind->banner = strdup(value);
if (sshbind->banner == NULL) { if (sshbind->banner == NULL) {
ssh_set_error_oom(sshbind); ssh_set_error_oom(sshbind);