Skip to content

fix: do not discard unread member data on empty buffer reads (#478) - #495

Open
slopgobblercobbler wants to merge 1 commit into
composefs:mainfrom
slopgobblercobbler:fix/empty-destination-read-preserve-data
Open

slopgobblercobbler wants to merge 1 commit into
composefs:mainfrom
slopgobblercobbler:fix/empty-destination-read-preserve-data

Conversation

@slopgobblercobbler

Copy link
Copy Markdown

Fixes #478.

When calling read on an Entry with an empty buffer (&mut []), EntryFields::read matches Some(Ok(0)) from the underlying EntryIo and removes self.data[0], treating zero bytes read as EOF. This discards unread member bytes for subsequent reads.

Per std::io::Read, reading into a zero-length slice should return Ok(0) immediately without advancing or consuming data. Returning Ok(0) when into.is_empty() keeps the current EntryIo entry intact.

Testing

Added empty_buffer_read_does_not_discard_data in tests/all.rs:

cargo test --test all empty_buffer_read_does_not_discard_data
cargo test --test all

All 74 tests in tests/all.rs pass.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Empty destination reads discard unread member data

1 participant