Conversation
__vector_as_array<T> calling ByteBuffer.ToArray<T> with the length in bytes by multiplying len with ByteBuffer.Sizeof<T> and FlatBuffersExampleTests extended to call GetVectorOfLongsArray/GetVectorOfDoublesArray which failed without the fix
add --format sln to the dotnet new command, maybe it is currently creating a .slnx instead?
- Test TestVerifyingTableWithRelativeOffsetAbove32k added, which failed without the fix - Fix Verifier.GetVRelOffset
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[C#] Fix incorrect offset type in verifier (#8937)
This is a fix for
private short GetVRelOffset(int pos, short vtableOffset), which doesn't calculate the vtable position correctly.Instead of
short vtable = Convert.ToInt16(pos - ReadSOffsetT(verifier_buffer, pos));it should be
int vtable = pos - ReadSOffsetT(verifier_buffer, pos);I added the Test TestVerifyingTableWithRelativeOffsetAbove32k, which failed without the fix:
D:\github\stefan301\flatbuffers\tests>D:\github\stefan301\flatbuffers\tests\FlatBuffers.Test\bin\Debug\net8.0\FlatBuffers.Test.exe
...
Exception: System.OverflowException: Value was either too large or too small for an Int16.
at System.Convert.ThrowInt16OverflowException()
at System.Convert.ToInt16(Int32 value)
at Google.FlatBuffers.Verifier.GetVRelOffset(Int32 pos, Int16 vtableOffset) in D:\github\stefan301\flatbuffers\net\FlatBuffers\FlatBufferVerify.cs:line 243
FlatBuffersExampleTests: FAILED when invoking TestVerifyingTableWithRelativeOffsetAbove32k with error Google.FlatBuffers.Test.AssertFailedException: Expected True but saw False
at Google.FlatBuffers.Test.Assert.AreEqual[T](T expected, T actual) in D:\github\stefan301\flatbuffers\tests\FlatBuffers.Test\Assert.cs:line 82
at Google.FlatBuffers.Test.FlatBuffersExampleTests.TestVerifyingTableWithRelativeOffsetAbove32k() in D:\github\stefan301\flatbuffers\tests\FlatBuffers.Test\FlatBuffersExampleTests.cs:line 1259
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
157 tests run, 1 failed
with the fix, all Tests succeed:
D:\github\stefan301\flatbuffers\tests>D:\github\stefan301\flatbuffers\tests\FlatBuffers.Test\bin\Debug\net8.0\FlatBuffers.Test.exe157 tests run, 0 failed