1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-25 01:02:24 +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); *retstr = dupstr(error);
sfree(rkey); sfree(rkey);
if (comment)
sfree(comment);
return PAGEANT_ACTION_FAILURE; return PAGEANT_ACTION_FAILURE;
} else if (ret == 1) { } else if (ret == 1) {
/* /*
@ -1309,6 +1311,8 @@ int pageant_add_keyfile(Filename *filename, const char *passphrase,
return PAGEANT_ACTION_FAILURE; return PAGEANT_ACTION_FAILURE;
} }
ssh_key_free(skey->key);
sfree(skey);
sfree(response); sfree(response);
} else { } else {
if (!pageant_add_ssh2_key(skey)) { if (!pageant_add_ssh2_key(skey)) {

View File

@ -658,6 +658,7 @@ static void test_mp_modsqrt(void)
} }
mp_free(x); mp_free(x);
modsqrt_free(sc);
} }
static WeierstrassCurve *wcurve(void) 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); ret = pollwrap_poll_endless(pw);
} while (ret < 0 && errno == EINTR); } while (ret < 0 && errno == EINTR);
assert(ret != 0); assert(ret != 0);
if (ret < 0) if (ret < 0) {
pollwrap_free(pw);
return ret; return ret;
}
assert(pollwrap_check_fd_rwx(pw, fd, SELECT_R)); assert(pollwrap_check_fd_rwx(pw, fd, SELECT_R));
} }

View File

@ -990,6 +990,7 @@ void run_agent(void)
} }
conf_free(conf); conf_free(conf);
pollwrap_free(pw);
} }
int main(int argc, char **argv) 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 *auth_kbdint_prompts(AuthPolicy *ap, ptrlen username)
{ {
AuthKbdInt *aki = snew(AuthKbdInt); AuthKbdInt *aki;
switch (ap->kbdint_state) { switch (ap->kbdint_state) {
case 0: case 0:
aki = snew(AuthKbdInt);
aki->title = dupstr("Initial double prompt"); aki->title = dupstr("Initial double prompt");
aki->instruction = aki->instruction =
dupstr("First prompt should echo, second should not"); 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; aki->prompts[1].echo = false;
return aki; return aki;
case 1: case 1:
aki = snew(AuthKbdInt);
aki->title = dupstr("Zero-prompt step"); aki->title = dupstr("Zero-prompt step");
aki->instruction = dupstr("Shouldn't see any prompts this time"); aki->instruction = dupstr("Shouldn't see any prompts this time");
aki->nprompts = 0; 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; for (fd = first_fd(&fdstate, &rwx); fd >= 0;
fd = next_fd(&fdstate, &rwx)) i++; 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 */ return -1; /* doom */
}
/* Expand the fdlist buffer if necessary. */ /* Expand the fdlist buffer if necessary. */
sgrowarray(fdlist, fdsize, i); sgrowarray(fdlist, fdsize, i);