Skip to content

Commit

Permalink
ensure writes don't pass max chunk size
Browse files Browse the repository at this point in the history
  • Loading branch information
lulf committed Apr 26, 2024
1 parent 9973a06 commit 308827a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ impl<H: Header> PageWriter<H> {
}

pub async fn write<F: Flash>(&mut self, flash: &mut F, data: &[u8]) -> Result<usize, Error<F::Error>> {
let max_write = PAGE_SIZE.saturating_sub(self.chunk_offset + ChunkHeader::SIZE + self.chunk_pos);
let max_write = PAGE_SIZE.saturating_sub(self.chunk_offset + ChunkHeader::SIZE + self.chunk_pos).min(MAX_CHUNK_SIZE);
let total_n = data.len().min(max_write);
if total_n == 0 {
return Ok(0);
Expand Down

0 comments on commit 308827a

Please sign in to comment.