From 29b8e26f7da86b08ab41e160f846bdf0438f9db7 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sat, 20 Feb 2021 16:39:12 +0000 Subject: [PATCH] Fix duplicated exit code in ppk_load_s. There's no need to have one bunch of free operations before returning success and another version before returning error. Easier to just set up the state in the former case so that we can fall through to the latter. --- sshpubk.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/sshpubk.c b/sshpubk.c index 88bfc1b3..7a009537 100644 --- a/sshpubk.c +++ b/sshpubk.c @@ -800,14 +800,13 @@ ssh2_userkey *ppk_load_s(BinarySource *src, const char *passphrase, goto error; } } - sfree(mac); - mac = NULL; /* * Create and return the key. */ ret = snew(ssh2_userkey); ret->comment = comment; + comment = NULL; ret->key = ssh_key_new_priv( alg, ptrlen_from_strbuf(public_blob), ptrlen_from_strbuf(private_blob)); @@ -817,12 +816,7 @@ ssh2_userkey *ppk_load_s(BinarySource *src, const char *passphrase, error = "createkey failed"; goto error; } - strbuf_free(public_blob); - strbuf_free(private_blob); - sfree(encryption); - if (errorstr) - *errorstr = NULL; - return ret; + error = NULL; /* * Error processing.