Skip to content

Commit

Permalink
Removed the use of the size of data returned from the C++ just use no…
Browse files Browse the repository at this point in the history
…rmal string logic. (#331)
  • Loading branch information
SteveMaier-IRT authored Sep 17, 2022
1 parent 9d559b4 commit ff69753
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ public unsafe string ToJson()
var status = NativeInterface.PlaintextBallot.ToJson(
Handle, out IntPtr pointer, out ulong size);
status.ThrowIfError();
var json = Marshal.PtrToStringAnsi(pointer, (int)size);
var json = Marshal.PtrToStringAnsi(pointer);
NativeInterface.Memory.FreeIntPtr(pointer);
return json;
}
Expand Down Expand Up @@ -1242,7 +1242,7 @@ public unsafe string ToJson(bool withNonces = false)
: NativeInterface.CiphertextBallot.ToJson(
Handle, out pointer, out size);
status.ThrowIfError();
var json = Marshal.PtrToStringAnsi(pointer, (int)size);
var json = Marshal.PtrToStringAnsi(pointer);
NativeInterface.Memory.FreeIntPtr(pointer);
return json;
}
Expand Down Expand Up @@ -1609,7 +1609,7 @@ public unsafe string ToJson()
var status = NativeInterface.SubmittedBallot.ToJson(
Handle, out IntPtr pointer, out ulong size);
status.ThrowIfError();
var json = Marshal.PtrToStringAnsi(pointer, (int)size);
var json = Marshal.PtrToStringAnsi(pointer);
NativeInterface.Memory.FreeIntPtr(pointer);
return json;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ public unsafe string ToJson()
var status = NativeInterface.CiphertextElectionContext.ToJson(
Handle, out IntPtr pointer, out ulong size);
status.ThrowIfError();
var json = Marshal.PtrToStringAnsi(pointer, (int)size);
var json = Marshal.PtrToStringAnsi(pointer);
NativeInterface.Memory.FreeIntPtr(pointer);
return json;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
<!-- Project -->
<RootNamespace>ElectionGuard</RootNamespace>
<AssemblyName>ElectionGuard.Encryption</AssemblyName>
<Version>0.1.17</Version>
<AssemblyVersion>0.1.17.0</AssemblyVersion>
<AssemblyFileVersion>0.1.17.0</AssemblyFileVersion>
<Version>0.1.18</Version>
<AssemblyVersion>0.1.18.0</AssemblyVersion>
<AssemblyFileVersion>0.1.18.0</AssemblyFileVersion>
</PropertyGroup>

<PropertyGroup>
Expand All @@ -19,7 +19,7 @@
<Title>ElectionGuard Encryption</Title>
<Description>Open source implementation of ElectionGuard's ballot encryption.</Description>
<Authors>Microsoft</Authors>
<PackageVersion>0.1.17</PackageVersion>
<PackageVersion>0.1.18</PackageVersion>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/microsoft/electionguard-cpp</PackageProjectUrl>
<RepositoryUrl>https://github.com/microsoft/electionguard-cpp</RepositoryUrl>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public unsafe string ToJson()
{
var status = NativeInterface.EncryptionDevice.ToJson(Handle, out IntPtr pointer, out ulong size);
status.ThrowIfError();
var json = Marshal.PtrToStringAnsi(pointer, (int)size);
var json = Marshal.PtrToStringAnsi(pointer);
NativeInterface.Memory.FreeIntPtr(pointer);
return json;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ public unsafe static string ToJson()
var status = NativeInterface.Constants.ToJson(
out IntPtr pointer, out ulong size);
status.ThrowIfError();
var json = Marshal.PtrToStringAnsi(pointer, (int)size);
var json = Marshal.PtrToStringAnsi(pointer);
NativeInterface.Memory.FreeIntPtr(pointer);
return json;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2454,7 +2454,7 @@ public unsafe string ToJson()
{
throw new ElectionGuardException($"ToJson Error Status: {status}");
}
var json = Marshal.PtrToStringAnsi(pointer, (int)size);
var json = Marshal.PtrToStringAnsi(pointer);
NativeInterface.Memory.FreeIntPtr(pointer);
return json;
}
Expand Down Expand Up @@ -2681,7 +2681,7 @@ public unsafe string ToJson()
{
throw new ElectionGuardException($"ToJson Error Status: {status}");
}
var json = Marshal.PtrToStringAnsi(pointer, (int)size);
var json = Marshal.PtrToStringAnsi(pointer);
NativeInterface.Memory.FreeIntPtr(pointer);
return json;
}
Expand Down

0 comments on commit ff69753

Please sign in to comment.