diff --git a/src/options.c b/src/options.c index 5a1698d2..1f849b64 100644 --- a/src/options.c +++ b/src/options.c @@ -2285,6 +2285,9 @@ ssh_bind_options_set(ssh_bind sshbind, SSH_FATAL, "The host key size %d is too small.", ssh_key_size(key)); + if (type != SSH_BIND_OPTIONS_IMPORT_KEY) { + SSH_KEY_FREE(key); + } return -1; } key_type = ssh_key_type(key); @@ -2330,6 +2333,11 @@ ssh_bind_options_set(ssh_bind sshbind, ssh_key_free(key); return -1; } + } else if (type == SSH_BIND_OPTIONS_IMPORT_KEY_STR) { + if (bind_key_loc == NULL) { + ssh_key_free(key); + return -1; + } } else { if (bind_key_loc == NULL) { return -1;