X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/4bcf919e38e8cacd8c06d6e6ffe11091f57fd4ab..d4963650de01d908eea5792e2a8dd0f72ea9d582:/sshpubk.c diff --git a/sshpubk.c b/sshpubk.c index fddc6e56..812a8e9a 100644 --- a/sshpubk.c +++ b/sshpubk.c @@ -71,11 +71,6 @@ static int loadrsakey_main(FILE * fp, struct RSAKey *key, int pub_only, if (i < 0) goto end; /* overran */ - if (pub_only) { - ret = 1; - goto end; - } - /* Next, the comment field. */ j = GET_32BIT(buf + i); i += 4; @@ -88,9 +83,17 @@ static int loadrsakey_main(FILE * fp, struct RSAKey *key, int pub_only, } i += j; if (commentptr) - *commentptr = comment; + *commentptr = dupstr(comment); if (key) key->comment = comment; + else + sfree(comment); + + if (pub_only) { + ret = 1; + goto end; + } + if (!key) { ret = ciphertype != 0; *error = NULL;