mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-09 18:04:25 +09: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_new(struct ssh_session *session) {
|
||||||
AGENT *agent = NULL;
|
AGENT *agent = NULL;
|
||||||
|
|
||||||
agent = calloc(1, sizeof(*agent));
|
agent = malloc(sizeof(AGENT));
|
||||||
if (agent) {
|
if (agent == NULL) {
|
||||||
agent->count = 0;
|
return NULL;
|
||||||
agent->sock = ssh_socket_new(session);
|
}
|
||||||
if (agent->sock == NULL) {
|
ZERO_STRUCTP(agent);
|
||||||
return NULL;
|
|
||||||
}
|
agent->count = 0;
|
||||||
|
agent->sock = ssh_socket_new(session);
|
||||||
|
if (agent->sock == NULL) {
|
||||||
|
SAFE_FREE(agent);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return agent;
|
return agent;
|
||||||
|
|||||||
Reference in New Issue
Block a user