Commit 5665cfe4 authored by Idan Sheinberg's avatar Idan Sheinberg Committed by Wouter van Oortmerssen

[Java] byte buffer factory returned buffer capcity is used instead of the requested size (#5558)

* byte buffer factory returned buffer is used instead of the requested capacity

* byte buffer factory returned buffer is used instead of the requested capacity

* Comment fix
parent 5797540e
......@@ -242,6 +242,7 @@ public class FlatBufferBuilder {
int new_buf_size = old_buf_size == 0 ? 1 : old_buf_size << 1;
bb.position(0);
ByteBuffer nbb = bb_factory.newByteBuffer(new_buf_size);
new_buf_size = nbb.clear().capacity(); // Ensure the returned buffer is treated as empty
nbb.position(new_buf_size - old_buf_size);
nbb.put(bb);
return nbb;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment