author | alfadur |
Mon, 25 Mar 2024 15:59:14 +0300 | |
changeset 16028 | d73e6cb37f83 |
parent 16027 | 14fe5bfe9862 |
child 16029 | d9f1b239b6d7 |
--- a/rust/hedgewars-server/src/protocol.rs Mon Mar 25 00:23:41 2024 +0300 +++ b/rust/hedgewars-server/src/protocol.rs Mon Mar 25 15:59:14 2024 +0300 @@ -102,8 +102,9 @@ use ProtocolError::*; loop { - if self.buffer.capacity() < 1024 { - self.buffer.reserve(1024 - self.buffer.capacity()); + let remaining = self.buffer.capacity() - self.buffer.len(); + if remaining < 1024 { + self.buffer.reserve(2048 - remaining); } if !self.buffer.has_remaining() || self.is_recovering {