Commit e057e411 by Brad Morgan

Reworked git_cred_ssh_keyfile_passphrase_new method

parent b54ed3ef
......@@ -90,47 +90,25 @@ int git_cred_ssh_keyfile_passphrase_new(
{
git_cred_ssh_keyfile_passphrase *c;
if (!cred)
return -1;
assert(cred && privatekey);
c = git__malloc(sizeof(git_cred_ssh_keyfile_passphrase));
c = git__calloc(1, sizeof(git_cred_ssh_keyfile_passphrase));
GITERR_CHECK_ALLOC(c);
c->parent.credtype = GIT_CREDTYPE_SSH_KEYFILE_PASSPHRASE;
c->parent.free = ssh_keyfile_passphrase_free;
c->privatekey = git__strdup(privatekey);
if (!c->privatekey) {
git__free(c);
return -1;
}
GITERR_CHECK_ALLOC(c->privatekey);
if (publickey) {
c->publickey = git__strdup(publickey);
if (!c->publickey) {
git__free(c->privatekey);
git__free(c);
return -1;
}
} else {
c->publickey = NULL;
GITERR_CHECK_ALLOC(c->publickey);
}
if (passphrase) {
c->passphrase = git__strdup(passphrase);
if (!c->passphrase) {
git__free(c->privatekey);
if (c->publickey) {
git__free(c->publickey);
}
git__free(c);
return -1;
}
} else {
c->passphrase = NULL;
GITERR_CHECK_ALLOC(c->passphrase);
}
*cred = &c->parent;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment