Skip to content

Commit 9d4534d

Browse files
KanouAoaardappel
authored andcommitted
Update Table.cs
Fix memory alignment issue: calculate correct byte length (element count × element size)
1 parent 7675121 commit 9d4534d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

net/FlatBuffers/Table.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,9 @@ public T[] __vector_as_array<T>(int offset)
150150

151151
var pos = this.__vector(o);
152152
var len = this.__vector_len(o);
153-
return bb.ToArray<T>(pos, len);
153+
// Fix memory alignment issue: calculate correct byte length (element count × element size)
154+
var byteLen = len * System.Runtime.InteropServices.Marshal.SizeOf<T>();
155+
return bb.ToArray<T>(pos, byteLen);
154156
}
155157

156158
// Initialize any Table-derived type to point to the union at the given offset.

0 commit comments

Comments
 (0)