Skip to content

[C#][version 23.1.21] can't add null string in string vector (or zero offset in vector) #7846

@phenixxy

Description

@phenixxy

schema:

table TestTable
{
  string_vector:[string];
}

test code:

var table = new TestTableT();
table.StringVector = new List<string>();
table.StringVector.Add(null);
var data = table.SerializeToBinary();
var table2 = TestTableT.DeserializeFromBinary(data);

exception:
ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Google.FlatBuffers.ByteBuffer.AssertOffsetAndLength (System.Int32 offset, System.Int32 length)
Google.FlatBuffers.ByteBuffer.ReadLittleEndian (System.Int32 offset, System.Int32 count)
Google.FlatBuffers.ByteBuffer.GetInt (System.Int32 index)
Google.FlatBuffers.Table.__string (System.Int32 offset)
TestTable.StringVector (System.Int32 j)
TestTable.UnPackTo (ExcelData.TestTableT _o)
TestTable.UnPack ()
TestTableT.DeserializeFromBinary (System.Byte[] fbBuffer)

issue:
Zero offset is not handled in FlatBufferBuilder.AddOffset, when creating vector. Zero offset is treated as relative offset to current position. So it's value can't be correctly unpacked.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions