Closed kckeiks closed 1 year ago
Given the definition of sizeof_len below, I noticed that we are also adding the length again when allocating vec capacity in serialize_into_vec. I think this might be a mistake?
sizeof_len
serialize_into_vec
https://github.com/tafia/quick-protobuf/blob/d977371e05170a016f03a80512b2a925468e3a1a/quick-protobuf/src/writer.rs#L313
pub fn sizeof_len(len: usize) -> usize { sizeof_varint(len as u64) + len }
Yep, thanks for catching that! I'll make the PR to fix this soon.
If I'm not wrong, I also think serialize_into_slice() checks out.len() < len, which doesn't account for the length of the length varint itself.
serialize_into_slice()
out.len() < len
Given the definition of
sizeof_len
below, I noticed that we are also adding the length again when allocating vec capacity inserialize_into_vec
. I think this might be a mistake?https://github.com/tafia/quick-protobuf/blob/d977371e05170a016f03a80512b2a925468e3a1a/quick-protobuf/src/writer.rs#L313