1
Fork 0

Handle special case where payload length is zero.

This commit is contained in:
Alex Helfet 2019-04-13 14:18:58 +01:00
parent 876a654211
commit c1f6499170

View file

@ -309,8 +309,13 @@ impl Codec {
_header, body, footer);
}
let decoded_len = cobs::decode(body, dest)
.map_err(|_| Error::CobsDecodeFailed)?;
let decoded_len =
if body.len() == 0 {
0
} else {
cobs::decode(body, dest)
.map_err(|_| Error::CobsDecodeFailed)?
};
let decoded = &dest[0..decoded_len];