diff options
author | Tim Clem <timothy.clem@gmail.com> | 2012-03-05 23:21:14 +0400 |
---|---|---|
committer | nulltoken <emeric.fermas@gmail.com> | 2012-03-06 15:39:13 +0400 |
commit | 69229e6c26e5fef43d54732421c88204a63f5aa5 (patch) | |
tree | 8eaf8482a2a3d18a9d21653997c4bdaff79dbd7b /LibGit2Sharp/Reference.cs | |
parent | 4f23c3488f581191d1f4e14fcfa4623298bd6081 (diff) |
Fix up marshalling of strings returned by libgit2
Previously we were doing this which is not good:
return Marshal.PtrToStringAnsi(intPtr);
You can see the failing test that was added to ConfigurationFixture.cs to
demonstrate the problem (setting and getting a user name with unicode chars in
the config). This brought up the large problem of how we were dealing with
libgit2 methods that returned string values.
There was another subtle issue in the Utf8Marshaler where we were freeing
memory that we didn't own.
Diffstat (limited to 'LibGit2Sharp/Reference.cs')
-rw-r--r-- | LibGit2Sharp/Reference.cs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/LibGit2Sharp/Reference.cs b/LibGit2Sharp/Reference.cs index 34dff799..50377123 100644 --- a/LibGit2Sharp/Reference.cs +++ b/LibGit2Sharp/Reference.cs @@ -32,7 +32,7 @@ namespace LibGit2Sharp return default(T); } - string name = NativeMethods.git_reference_name(ptr).MarshallAsString(); + string name = NativeMethods.git_reference_name(ptr); GitReferenceType type = NativeMethods.git_reference_type(ptr); Reference reference; @@ -41,7 +41,7 @@ namespace LibGit2Sharp { case GitReferenceType.Symbolic: IntPtr resolveRef; - var targetIdentifier = NativeMethods.git_reference_target(ptr).MarshallAsString(); + var targetIdentifier = NativeMethods.git_reference_target(ptr); int res = NativeMethods.git_reference_resolve(out resolveRef, ptr); if (res == (int)GitErrorCode.GIT_ENOTFOUND) |