mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-28 08:08:05 +00:00
Issue #188
When accessing the array directly of a byte buffer, need to offset by ``arrayOffset``
This commit is contained in:
@@ -45,7 +45,7 @@ public class Table {
|
|||||||
protected String __string(int offset) {
|
protected String __string(int offset) {
|
||||||
offset += bb.getInt(offset);
|
offset += bb.getInt(offset);
|
||||||
if (bb.hasArray()) {
|
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 {
|
} else {
|
||||||
// We can't access .array(), since the ByteBuffer is read-only,
|
// We can't access .array(), since the ByteBuffer is read-only,
|
||||||
// off-heap or a memory map
|
// off-heap or a memory map
|
||||||
|
|||||||
Reference in New Issue
Block a user