1
1

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
Этот коммит содержится в:
Andreas Schneider 2009-04-03 08:41:34 +00:00
родитель 41dd2a2a3b
Коммит 5a75c0fd78

@ -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;