diff options
-rw-r--r-- | net/FlatBuffers/FlatBufferBuilder.cs | 3 | ||||
-rw-r--r-- | net/FlatBuffers/Table.cs | 6 |
2 files changed, 7 insertions, 2 deletions
diff --git a/net/FlatBuffers/FlatBufferBuilder.cs b/net/FlatBuffers/FlatBufferBuilder.cs index e550f90f..e08db847 100644 --- a/net/FlatBuffers/FlatBufferBuilder.cs +++ b/net/FlatBuffers/FlatBufferBuilder.cs @@ -438,7 +438,8 @@ namespace Google.FlatBuffers if (off > Offset) throw new ArgumentException(); - off = Offset - off + sizeof(int); + if (off != 0) + off = Offset - off + sizeof(int); PutInt(off); } diff --git a/net/FlatBuffers/Table.cs b/net/FlatBuffers/Table.cs index 21ef7dc8..2aaa86e9 100644 --- a/net/FlatBuffers/Table.cs +++ b/net/FlatBuffers/Table.cs @@ -65,7 +65,11 @@ namespace Google.FlatBuffers // Create a .NET String from UTF-8 data stored inside the flatbuffer. public string __string(int offset) { - offset += bb.GetInt(offset); + int stringOffset = bb.GetInt(offset); + if (stringOffset == 0) + return null; + + offset += stringOffset; var len = bb.GetInt(offset); var startPos = offset + sizeof(int); return bb.GetStringUTF8(startPos, len); |