Fixed a bug in the Java code generation that would generate the wrong identifier in some cases.
Also added a safety check for buffers growing past 2 gigabytes. Change-Id: I2bca7159f606cf1c08c4391e88ef9b4c8363be06 Tested: With the Java sdk.
This commit is contained in:
parent
1485180517
commit
41a6d35e74
|
@ -57,7 +57,9 @@ public class FlatBufferBuilder {
|
|||
ByteBuffer growByteBuffer(ByteBuffer bb) {
|
||||
byte[] old_buf = bb.array();
|
||||
int old_buf_size = old_buf.length;
|
||||
int new_buf_size = old_buf_size * 2;
|
||||
if ((old_buf_size & 0xC0000000) != 0)
|
||||
throw new AssertionError("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");
|
||||
int new_buf_size = old_buf_size << 1;
|
||||
byte[] new_buf = new byte[new_buf_size];
|
||||
System.arraycopy(old_buf, 0, new_buf, new_buf_size - old_buf_size, old_buf_size);
|
||||
ByteBuffer nbb = newByteBuffer(new_buf);
|
||||
|
|
|
@ -255,7 +255,7 @@ static void GenStruct(StructDef &struct_def,
|
|||
code += "obj.__init(";
|
||||
code += field.value.type.struct_def->fixed
|
||||
? "o + bb_pos"
|
||||
: "__indirect(o + i)";
|
||||
: "__indirect(o + bb_pos)";
|
||||
code += ", bb) : null";
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue