[wpiutil] ProtobufBuffer: Fix buffer reallocation (#5924)

This commit is contained in:
Peter Johnson
2023-11-13 15:49:41 -08:00
committed by GitHub
parent c5f2f6a0fb
commit d105f9e3e9

View File

@@ -61,7 +61,7 @@ public final class ProtobufBuffer<T, MessageType extends ProtoMessage<?>> {
m_msg.clearQuick();
m_proto.pack(m_msg, value);
int size = m_msg.getSerializedSize();
if (size < m_buf.capacity()) {
if (size > m_buf.capacity()) {
m_buf = ByteBuffer.allocateDirect(size * 2);
m_sink.setOutput(m_buf);
}