Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2sharp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Hescock <chescock@vistaprint.com>2015-11-19 23:11:34 +0300
committerChris Hescock <chescock@vistaprint.com>2015-11-20 21:58:06 +0300
commit4f7e6287cbfecacc910274fddd7ea0452ff1a5ef (patch)
tree8141e40bd8ea5e14a602eb47fc2a511946f8608e
parentf8c944be073b787f4d45e59a91ecb571ade33e40 (diff)
Handle exceptions and null returns from CredentialsProvider.
-rw-r--r--LibGit2Sharp/RemoteCallbacks.cs18
1 files changed, 15 insertions, 3 deletions
diff --git a/LibGit2Sharp/RemoteCallbacks.cs b/LibGit2Sharp/RemoteCallbacks.cs
index 42037a22..678fb84e 100644
--- a/LibGit2Sharp/RemoteCallbacks.cs
+++ b/LibGit2Sharp/RemoteCallbacks.cs
@@ -285,9 +285,21 @@ namespace LibGit2Sharp
types |= SupportedCredentialTypes.Default;
}
- var cred = CredentialsProvider(url, username, types);
-
- return cred.GitCredentialHandler(out ptr);
+ ptr = IntPtr.Zero;
+ try
+ {
+ var cred = CredentialsProvider(url, username, types);
+ if (cred == null)
+ {
+ return (int)GitErrorCode.PassThrough;
+ }
+ return cred.GitCredentialHandler(out ptr);
+ }
+ catch (Exception exception)
+ {
+ Proxy.giterr_set_str(GitErrorCategory.Callback, exception);
+ return (int)GitErrorCode.Error;
+ }
}
private int GitCertificateCheck(IntPtr certPtr, int valid, IntPtr cHostname, IntPtr payload)