Commit 219f318c051a37c05dd66687695ebec9f1a90e53

Etienne Samson 2013-07-03T22:02:29

Fix a crash if git_remote_set_cred_acquire_cb wasn't called before connecting. Fixes #1700.

diff --git a/src/transports/ssh.c b/src/transports/ssh.c
index a312c8d..8e3657d 100644
--- a/src/transports/ssh.c
+++ b/src/transports/ssh.c
@@ -345,14 +345,16 @@ static int _git_ssh_setup_conn(
 	if (user && pass) {
 		if (git_cred_userpass_plaintext_new(&t->cred, user, pass) < 0)
 			goto on_error;
-	} else {
+	} else if (t->owner->cred_acquire_cb) {
 		if (t->owner->cred_acquire_cb(&t->cred,
 				t->owner->url,
 				user,
 				GIT_CREDTYPE_USERPASS_PLAINTEXT | GIT_CREDTYPE_SSH_KEYFILE_PASSPHRASE,
 				t->owner->cred_acquire_payload) < 0)
 			return -1;
-	}
+	} else {
+        goto on_error;
+    }
 	assert(t->cred);
 	
 	if (!user) {