tokio-rs / bytes

Utilities for working with bytes
MIT License
1.91k stars 288 forks source link

Chain of two large (i.e. BytesMut) panics #550

Closed jasl8r closed 2 years ago

jasl8r commented 2 years ago

When chaining two spacious buffers, as in unbounded BytesMut, the remaining and remaining_mut fn both panic due to overflow when adding together the two child remaining. Obviously BytesMut acts as though it is infinite and this happens. I don't know if I'm dumb for chaining two infinite buffers, but it was just the simple way for me to start testing out Bytes and a Chain. The fix is of course simple, just change the unwrap to unwrap_or(usize::MAX).

taiki-e commented 2 years ago

This will be fixed by https://github.com/tokio-rs/bytes/pull/488.

taiki-e commented 2 years ago

488 merged