From: Simon Tatham Date: Sun, 26 Apr 2015 09:49:24 +0000 (+0100) Subject: Fix a few memory leaks. X-Git-Tag: 0.68~615 X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=78989c97c94ef45b7081d80df1c35f2cc1edfea0;hp=84e239dd88245cd3308de987b2b0fd6637b2db34;p=PuTTY.git Fix a few memory leaks. Patch due to Chris Staite. --- diff --git a/ssh.c b/ssh.c index eb797589..0cc27c93 100644 --- a/ssh.c +++ b/ssh.c @@ -9538,6 +9538,8 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, logevent("Sent public key signature"); s->type = AUTH_TYPE_PUBLICKEY; key->alg->freekey(key->data); + sfree(key->comment); + sfree(key); } #ifndef NO_GSSAPI diff --git a/sshpubk.c b/sshpubk.c index 11182283..8b80f389 100644 --- a/sshpubk.c +++ b/sshpubk.c @@ -843,7 +843,7 @@ unsigned char *ssh2_userkey_loadpub(const Filename *filename, char **algorithm, int public_blob_len; int i; const char *error = NULL; - char *comment; + char *comment = NULL; public_blob = NULL; @@ -868,11 +868,10 @@ unsigned char *ssh2_userkey_loadpub(const Filename *filename, char **algorithm, goto error; /* Select key algorithm structure. */ alg = find_pubkey_alg(b); + sfree(b); if (!alg) { - sfree(b); goto error; } - sfree(b); /* Read the Encryption header line. */ if (!read_header(fp, header) || 0 != strcmp(header, "Encryption")) @@ -919,6 +918,10 @@ unsigned char *ssh2_userkey_loadpub(const Filename *filename, char **algorithm, sfree(public_blob); if (errorstr) *errorstr = error; + if (comment && commentptr) { + sfree(comment); + *commentptr = NULL; + } return NULL; }