Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

serialize_into corrupts buffer when it fails #403

Open
behzadnouri opened this issue Aug 22, 2021 · 1 comment
Open

serialize_into corrupts buffer when it fails #403

behzadnouri opened this issue Aug 22, 2021 · 1 comment

Comments

@behzadnouri
Copy link

The documentation for serialize_into claims that:

If the serialization would take more bytes than allowed by the size limit, an error
is returned and no bytes will be written into the Writer.
https://github.com/bincode-org/bincode/blob/4b6c808db/src/lib.rs#L63-L64

Testing this with some

let mut buffer = vec![u8; 10];
let _ = bincode::serialize_into(&mut buffer[..], &object);

shows that the buffer is mutated even if the serialization fails due to buffer being too small.

@ZoeyR
Copy link
Collaborator

ZoeyR commented Aug 23, 2021

The size limit referred to in that documentation is the limit parameter from Options. It looks like this was a copy and paste error from the documentation for the method on the Options trait. This should be made more clear in the docs though since serialize_into at this position takes no config parameter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants