Skip to content

Commit ff69753

Browse files
Removed the use of the size of data returned from the C++ just use normal string logic. (#331)
1 parent 9d559b4 commit ff69753

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Ballot.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,7 @@ public unsafe string ToJson()
909909
var status = NativeInterface.PlaintextBallot.ToJson(
910910
Handle, out IntPtr pointer, out ulong size);
911911
status.ThrowIfError();
912-
var json = Marshal.PtrToStringAnsi(pointer, (int)size);
912+
var json = Marshal.PtrToStringAnsi(pointer);
913913
NativeInterface.Memory.FreeIntPtr(pointer);
914914
return json;
915915
}
@@ -1242,7 +1242,7 @@ public unsafe string ToJson(bool withNonces = false)
12421242
: NativeInterface.CiphertextBallot.ToJson(
12431243
Handle, out pointer, out size);
12441244
status.ThrowIfError();
1245-
var json = Marshal.PtrToStringAnsi(pointer, (int)size);
1245+
var json = Marshal.PtrToStringAnsi(pointer);
12461246
NativeInterface.Memory.FreeIntPtr(pointer);
12471247
return json;
12481248
}
@@ -1609,7 +1609,7 @@ public unsafe string ToJson()
16091609
var status = NativeInterface.SubmittedBallot.ToJson(
16101610
Handle, out IntPtr pointer, out ulong size);
16111611
status.ThrowIfError();
1612-
var json = Marshal.PtrToStringAnsi(pointer, (int)size);
1612+
var json = Marshal.PtrToStringAnsi(pointer);
16131613
NativeInterface.Memory.FreeIntPtr(pointer);
16141614
return json;
16151615
}

bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Election.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ public unsafe string ToJson()
316316
var status = NativeInterface.CiphertextElectionContext.ToJson(
317317
Handle, out IntPtr pointer, out ulong size);
318318
status.ThrowIfError();
319-
var json = Marshal.PtrToStringAnsi(pointer, (int)size);
319+
var json = Marshal.PtrToStringAnsi(pointer);
320320
NativeInterface.Memory.FreeIntPtr(pointer);
321321
return json;
322322
}

bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/ElectionGuard.Encryption.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
<!-- Project -->
88
<RootNamespace>ElectionGuard</RootNamespace>
99
<AssemblyName>ElectionGuard.Encryption</AssemblyName>
10-
<Version>0.1.17</Version>
11-
<AssemblyVersion>0.1.17.0</AssemblyVersion>
12-
<AssemblyFileVersion>0.1.17.0</AssemblyFileVersion>
10+
<Version>0.1.18</Version>
11+
<AssemblyVersion>0.1.18.0</AssemblyVersion>
12+
<AssemblyFileVersion>0.1.18.0</AssemblyFileVersion>
1313
</PropertyGroup>
1414

1515
<PropertyGroup>
@@ -19,7 +19,7 @@
1919
<Title>ElectionGuard Encryption</Title>
2020
<Description>Open source implementation of ElectionGuard's ballot encryption.</Description>
2121
<Authors>Microsoft</Authors>
22-
<PackageVersion>0.1.17</PackageVersion>
22+
<PackageVersion>0.1.18</PackageVersion>
2323
<PackageLicenseExpression>MIT</PackageLicenseExpression>
2424
<PackageProjectUrl>https://github.com/microsoft/electionguard-cpp</PackageProjectUrl>
2525
<RepositoryUrl>https://github.com/microsoft/electionguard-cpp</RepositoryUrl>

bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Encrypt.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public unsafe string ToJson()
6868
{
6969
var status = NativeInterface.EncryptionDevice.ToJson(Handle, out IntPtr pointer, out ulong size);
7070
status.ThrowIfError();
71-
var json = Marshal.PtrToStringAnsi(pointer, (int)size);
71+
var json = Marshal.PtrToStringAnsi(pointer);
7272
NativeInterface.Memory.FreeIntPtr(pointer);
7373
return json;
7474
}

bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Group.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ public unsafe static string ToJson()
415415
var status = NativeInterface.Constants.ToJson(
416416
out IntPtr pointer, out ulong size);
417417
status.ThrowIfError();
418-
var json = Marshal.PtrToStringAnsi(pointer, (int)size);
418+
var json = Marshal.PtrToStringAnsi(pointer);
419419
NativeInterface.Memory.FreeIntPtr(pointer);
420420
return json;
421421
}

bindings/netstandard/ElectionGuard/ElectionGuard.Encryption/Manifest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2454,7 +2454,7 @@ public unsafe string ToJson()
24542454
{
24552455
throw new ElectionGuardException($"ToJson Error Status: {status}");
24562456
}
2457-
var json = Marshal.PtrToStringAnsi(pointer, (int)size);
2457+
var json = Marshal.PtrToStringAnsi(pointer);
24582458
NativeInterface.Memory.FreeIntPtr(pointer);
24592459
return json;
24602460
}
@@ -2681,7 +2681,7 @@ public unsafe string ToJson()
26812681
{
26822682
throw new ElectionGuardException($"ToJson Error Status: {status}");
26832683
}
2684-
var json = Marshal.PtrToStringAnsi(pointer, (int)size);
2684+
var json = Marshal.PtrToStringAnsi(pointer);
26852685
NativeInterface.Memory.FreeIntPtr(pointer);
26862686
return json;
26872687
}

0 commit comments

Comments
 (0)