Skip to content

Commit

Permalink
prevent panic with saturating_sub on max_bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
shortishly committed Oct 7, 2024
1 parent c367bcc commit 52919dc
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tansu-server/src/broker/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ where
.inspect_err(|error| error!(?tp, ?error))
.map_or(Vec::new(), |batch| vec![batch]);

*max_bytes -= u32::try_from(fetched.byte_size())?;
*max_bytes =
u32::try_from(fetched.byte_size()).map(|bytes| max_bytes.saturating_sub(bytes))?;

debug!(?offset, ?fetched);

Expand Down

0 comments on commit 52919dc

Please sign in to comment.