]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Fix a few memory leaks.
authorSimon Tatham <anakin@pobox.com>
Sun, 26 Apr 2015 09:49:24 +0000 (10:49 +0100)
committerSimon Tatham <anakin@pobox.com>
Sat, 20 Jun 2015 08:31:55 +0000 (09:31 +0100)
Patch due to Chris Staite.

(cherry picked from commit 78989c97c94ef45b7081d80df1c35f2cc1edfea0)

ssh.c
sshpubk.c

diff --git a/ssh.c b/ssh.c
index 735bc17460063034ff20d2f2d9e6ac7eeec519a8..368cabef9a5ef1500e6ea7cafa29e5a94bc2cb57 100644 (file)
--- a/ssh.c
+++ b/ssh.c
@@ -9458,6 +9458,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
index 63b54b12e3ccec9bb103dd076ba8b6c0930a43cd..a4ecb9d5c846082a6f82c4d9d783b148e27cc36b 100644 (file)
--- a/sshpubk.c
+++ b/sshpubk.c
@@ -837,7 +837,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;
 
@@ -862,11 +862,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"))
@@ -913,6 +912,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;
 }