mirror of
https://github.com/vee1e/flatbuffers.git
synced 2026-09-01 17:57:25 +00:00
Fix for Java infinite loop encoding into 0-sized buffer (#4654)
This commit is contained in:
parent
ec74f58b94
commit
0068b25132
1 changed files with 1 additions and 1 deletions
|
|
@ -196,7 +196,7 @@ public class FlatBufferBuilder {
|
|||
int old_buf_size = bb.capacity();
|
||||
if ((old_buf_size & 0xC0000000) != 0) // Ensure we don't grow beyond what fits in an int.
|
||||
throw new AssertionError("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");
|
||||
int new_buf_size = old_buf_size << 1;
|
||||
int new_buf_size = old_buf_size == 0 ? 1 : old_buf_size << 1;
|
||||
bb.position(0);
|
||||
ByteBuffer nbb = bb_factory.newByteBuffer(new_buf_size);
|
||||
nbb.position(new_buf_size - old_buf_size);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue