1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 09:27:59 +00:00

Fix miscellaneous minor memory leaks.

All found by Coverity.
This commit is contained in:
Simon Tatham 2019-05-04 16:19:13 +01:00
parent e82ba498ff
commit 64fdc85b2d
6 changed files with 15 additions and 3 deletions

View File

@ -1213,6 +1213,8 @@ int pageant_add_keyfile(Filename *filename, const char *passphrase,
*/
*retstr = dupstr(error);
sfree(rkey);
if (comment)
sfree(comment);
return PAGEANT_ACTION_FAILURE;
} else if (ret == 1) {
/*
@ -1309,6 +1311,8 @@ int pageant_add_keyfile(Filename *filename, const char *passphrase,
return PAGEANT_ACTION_FAILURE;
}
ssh_key_free(skey->key);
sfree(skey);
sfree(response);
} else {
if (!pageant_add_ssh2_key(skey)) {

View File

@ -658,6 +658,7 @@ static void test_mp_modsqrt(void)
}
mp_free(x);
modsqrt_free(sc);
}
static WeierstrassCurve *wcurve(void)

View File

@ -142,8 +142,10 @@ static int block_and_read(int fd, void *buf, size_t len)
ret = pollwrap_poll_endless(pw);
} while (ret < 0 && errno == EINTR);
assert(ret != 0);
if (ret < 0)
if (ret < 0) {
pollwrap_free(pw);
return ret;
}
assert(pollwrap_check_fd_rwx(pw, fd, SELECT_R));
}

View File

@ -990,6 +990,7 @@ void run_agent(void)
}
conf_free(conf);
pollwrap_free(pw);
}
int main(int argc, char **argv)

View File

@ -235,10 +235,11 @@ RSAKey *auth_publickey_ssh1(
}
AuthKbdInt *auth_kbdint_prompts(AuthPolicy *ap, ptrlen username)
{
AuthKbdInt *aki = snew(AuthKbdInt);
AuthKbdInt *aki;
switch (ap->kbdint_state) {
case 0:
aki = snew(AuthKbdInt);
aki->title = dupstr("Initial double prompt");
aki->instruction =
dupstr("First prompt should echo, second should not");
@ -250,6 +251,7 @@ AuthKbdInt *auth_kbdint_prompts(AuthPolicy *ap, ptrlen username)
aki->prompts[1].echo = false;
return aki;
case 1:
aki = snew(AuthKbdInt);
aki->title = dupstr("Zero-prompt step");
aki->instruction = dupstr("Shouldn't see any prompts this time");
aki->nprompts = 0;

View File

@ -488,8 +488,10 @@ static int ssh_sftp_do_select(bool include_stdin, bool no_fds_ok)
for (fd = first_fd(&fdstate, &rwx); fd >= 0;
fd = next_fd(&fdstate, &rwx)) i++;
if (i < 1 && !no_fds_ok && !toplevel_callback_pending())
if (i < 1 && !no_fds_ok && !toplevel_callback_pending()) {
pollwrap_free(pw);
return -1; /* doom */
}
/* Expand the fdlist buffer if necessary. */
sgrowarray(fdlist, fdsize, i);