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

session: Don't leak memory in ssh_send_debug().

Found by Coverity.
This commit is contained in:
Andreas Schneider
2012-10-08 21:16:56 +02:00
parent dde3deb9ea
commit 802e4133cb

View File

@@ -673,6 +673,7 @@ error:
*/ */
int ssh_send_debug (ssh_session session, const char *message, int always_display) { int ssh_send_debug (ssh_session session, const char *message, int always_display) {
ssh_string str; ssh_string str;
int rc;
if (ssh_socket_is_open(session->socket)) { if (ssh_socket_is_open(session->socket)) {
if (buffer_add_u8(session->out_buffer, SSH2_MSG_DEBUG) < 0) { if (buffer_add_u8(session->out_buffer, SSH2_MSG_DEBUG) < 0) {
@@ -688,8 +689,9 @@ int ssh_send_debug (ssh_session session, const char *message, int always_display
goto error; goto error;
} }
if (buffer_add_ssh_string(session->out_buffer,str) < 0) { rc = buffer_add_ssh_string(session->out_buffer, str);
ssh_string_free(str); ssh_string_free(str);
if (rc < 0) {
goto error; goto error;
} }
@@ -700,8 +702,6 @@ int ssh_send_debug (ssh_session session, const char *message, int always_display
packet_send(session); packet_send(session);
ssh_handle_packets(session, 0); ssh_handle_packets(session, 0);
ssh_string_free(str);
} }
return SSH_OK; return SSH_OK;