mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-29 09:41:34 +00:00
Fix potential panic in ping (#342)
This commit is contained in:
@ -277,6 +277,7 @@ impl Encoder for Codec {
|
|||||||
fn encode(&mut self, mut data: Bytes, buf: &mut BytesMut) -> Result<(), IoError> {
|
fn encode(&mut self, mut data: Bytes, buf: &mut BytesMut) -> Result<(), IoError> {
|
||||||
if data.len() != 0 {
|
if data.len() != 0 {
|
||||||
let split = 32 * (1 + ((data.len() - 1) / 32));
|
let split = 32 * (1 + ((data.len() - 1) / 32));
|
||||||
|
buf.reserve(split);
|
||||||
buf.put(data.split_to(split));
|
buf.put(data.split_to(split));
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
Reference in New Issue
Block a user