When accessing the array directly of a byte buffer, need to offset
by ``arrayOffset``
This commit is contained in:
pjulien
2015-05-09 14:08:28 -04:00
parent 39833d7cf0
commit d322eec3c3

View File

@@ -45,7 +45,7 @@ public class Table {
protected String __string(int offset) {
offset += bb.getInt(offset);
if (bb.hasArray()) {
return new String(bb.array(), offset + SIZEOF_INT, bb.getInt(offset), FlatBufferBuilder.utf8charset);
return new String(bb.array(), bb.arrayOffset() + offset + SIZEOF_INT, bb.getInt(offset), FlatBufferBuilder.utf8charset);
} else {
// We can't access .array(), since the ByteBuffer is read-only,
// off-heap or a memory map