aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2012-10-08 20:46:35 +0200
committerAndreas Schneider <asn@cryptomilk.org>2012-10-12 08:07:01 +0200
commita6e7d1f255bd1ac5df3366c985487fc1e13d33a3 (patch)
tree9b1e880c97ae208cafd4cf48be6c5af82fa3ebcd
parentf2c183b4139f364f5ca697345d4b90df9549fdcf (diff)
downloadlibssh-a6e7d1f255bd1ac5df3366c985487fc1e13d33a3.tar.gz
libssh-a6e7d1f255bd1ac5df3366c985487fc1e13d33a3.tar.xz
libssh-a6e7d1f255bd1ac5df3366c985487fc1e13d33a3.zip
agent: Fix some memory leaks in error paths.
Found by Coverity.
-rw-r--r--src/agent.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/agent.c b/src/agent.c
index ecf23925..9944c287 100644
--- a/src/agent.c
+++ b/src/agent.c
@@ -295,12 +295,14 @@ int ssh_agent_get_ident_count(struct ssh_session_struct *session) {
reply = ssh_buffer_new();
if (reply == NULL) {
+ ssh_buffer_free(request);
ssh_set_error(session, SSH_FATAL, "Not enough space");
return -1;
}
if (agent_talk(session, request, reply) < 0) {
ssh_buffer_free(request);
+ ssh_buffer_free(reply);
return 0;
}
ssh_buffer_free(request);
@@ -440,6 +442,7 @@ ssh_string ssh_agent_sign_data(ssh_session session,
/* create request */
if (buffer_add_u8(request, SSH2_AGENTC_SIGN_REQUEST) < 0) {
+ ssh_buffer_free(request);
return NULL;
}
@@ -482,6 +485,7 @@ ssh_string ssh_agent_sign_data(ssh_session session,
/* send the request */
if (agent_talk(session, request, reply) < 0) {
ssh_buffer_free(request);
+ ssh_buffer_free(reply);
return NULL;
}
ssh_buffer_free(request);