mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-08-10 06:23:01 +03:00
Don't leak memory in agent_new() error path.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@378 7dcaeef0-15fb-0310-b436-a5af3365683c
This commit is contained in:
@@ -119,13 +119,17 @@ static size_t atomicio(struct socket *s, void *buf, size_t n, int do_read) {
|
||||
AGENT *agent_new(struct ssh_session *session) {
|
||||
AGENT *agent = NULL;
|
||||
|
||||
agent = calloc(1, sizeof(*agent));
|
||||
if (agent) {
|
||||
agent->count = 0;
|
||||
agent->sock = ssh_socket_new(session);
|
||||
if (agent->sock == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
agent = malloc(sizeof(AGENT));
|
||||
if (agent == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
ZERO_STRUCTP(agent);
|
||||
|
||||
agent->count = 0;
|
||||
agent->sock = ssh_socket_new(session);
|
||||
if (agent->sock == NULL) {
|
||||
SAFE_FREE(agent);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return agent;
|
||||
|
Reference in New Issue
Block a user