FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix assorted minor memory leaks. · github/putty@44adc8b · GitHub

This repository was archived by the owner on Oct 20, 2023. It is now read-only.
/ putty Public archive

Commit 44adc8b

Browse files
committed
Fix assorted minor memory leaks.
All found by Coverity.
1 parent 08f1e2a commit 44adc8b

7 files changed

Lines changed: 16 additions & 5 deletions

File tree

‎config.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1429,7 +1429,7 @@ static void clipboard_selector_handler(union control *ctrl, dlgparam *dlg,
14291429
#endif
14301430
) {
14311431
#ifdef NAMED_CLIPBOARDS
1432-
const char *sval = dlg_editbox_get(ctrl, dlg);
1432+
char *sval = dlg_editbox_get(ctrl, dlg);
14331433
int i;
14341434

14351435
for (i = 0; i < lenof(options); i++)
@@ -1444,6 +1444,8 @@ static void clipboard_selector_handler(union control *ctrl, dlgparam *dlg,
14441444
sval++;
14451445
conf_set_str(conf, strsetting, sval);
14461446
}
1447+
1448+
sfree(sval);
14471449
#else
14481450
int index = dlg_listbox_index(ctrl, dlg);
14491451
if (index >= 0) {

‎import.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,8 +538,10 @@ static ssh2_userkey *openssh_pem_read(
538538
strbuf *blob = strbuf_new_nm();
539539
int privptr = 0, publen;
540540

541-
if (!key)
541+
if (!key) {
542+
strbuf_free(blob);
542543
return NULL;
544+
}
543545

544546
if (key->encrypted) {
545547
unsigned char keybuf[32];

‎pageant.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,6 +1290,9 @@ int pageant_add_keyfile(Filename *filename, const char *passphrase,
12901290
if (resplen < 5 || response[4] != SSH_AGENT_SUCCESS) {
12911291
*retstr = dupstr("The already running Pageant "
12921292
"refused to add the key.");
1293+
sfree(skey->comment);
1294+
ssh_key_free(skey->key);
1295+
sfree(skey);
12931296
sfree(response);
12941297
return PAGEANT_ACTION_FAILURE;
12951298
}

‎sesschan.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -640,10 +640,10 @@ static void sesschan_notify_remote_exit(Seat *seat)
640640
sshfwd_send_exit_signal(
641641
sess->c, signame, false, ptrlen_from_asciz(sigmsg));
642642

643-
sfree(sigmsg);
644-
645643
got_signal = true;
646644
}
645+
646+
sfree(sigmsg);
647647
} else {
648648
int signum = pty_backend_exit_signum(sess->backend);
649649

‎sshdss.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,10 @@ static char *dss_cache_str(ssh_key *key)
7272
struct dss_key *dss = container_of(key, struct dss_key, sshk);
7373
strbuf *sb = strbuf_new();
7474

75-
if (!dss->p)
75+
if (!dss->p) {
76+
strbuf_free(sb);
7677
return NULL;
78+
}
7779

7880
append_hex_to_strbuf(sb, dss->p);
7981
append_hex_to_strbuf(sb, dss->q);

‎unix/uxagentsock.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Socket *platform_make_agent_socket(
2929
if ((errw = make_dir_and_check_ours(socketdir)) != NULL) {
3030
*error = dupprintf("%s: %s\n", socketdir, errw);
3131
sfree(errw);
32+
sfree(socketdir);
3233
return NULL;
3334
}
3435

‎unix/uxsftp.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,7 @@ static int ssh_sftp_do_select(bool include_stdin, bool no_fds_ok)
490490

491491
if (i < 1 && !no_fds_ok && !toplevel_callback_pending()) {
492492
pollwrap_free(pw);
493+
sfree(fdlist);
493494
return -1; /* doom */
494495
}
495496

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL