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( ...@@ -90,47 +90,25 @@ int git_cred_ssh_keyfile_passphrase_new(
{ {
git_cred_ssh_keyfile_passphrase *c; git_cred_ssh_keyfile_passphrase *c;
if (!cred) assert(cred && privatekey);
return -1;
c = git__malloc(sizeof(git_cred_ssh_keyfile_passphrase)); c = git__calloc(1, sizeof(git_cred_ssh_keyfile_passphrase));
GITERR_CHECK_ALLOC(c); GITERR_CHECK_ALLOC(c);
c->parent.credtype = GIT_CREDTYPE_SSH_KEYFILE_PASSPHRASE; c->parent.credtype = GIT_CREDTYPE_SSH_KEYFILE_PASSPHRASE;
c->parent.free = ssh_keyfile_passphrase_free; c->parent.free = ssh_keyfile_passphrase_free;
c->privatekey = git__strdup(privatekey); c->privatekey = git__strdup(privatekey);
GITERR_CHECK_ALLOC(c->privatekey);
if (!c->privatekey) {
git__free(c);
return -1;
}
if (publickey) { if (publickey) {
c->publickey = git__strdup(publickey); c->publickey = git__strdup(publickey);
GITERR_CHECK_ALLOC(c->publickey);
if (!c->publickey) {
git__free(c->privatekey);
git__free(c);
return -1;
}
} else {
c->publickey = NULL;
} }
if (passphrase) { if (passphrase) {
c->passphrase = git__strdup(passphrase); c->passphrase = git__strdup(passphrase);
GITERR_CHECK_ALLOC(c->passphrase);
if (!c->passphrase) {
git__free(c->privatekey);
if (c->publickey) {
git__free(c->publickey);
}
git__free(c);
return -1;
}
} else {
c->passphrase = NULL;
} }
*cred = &c->parent; *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