Skip to content

Commit

Permalink
Further defend ChunkVecBuffer::prefix_used invariant
Browse files Browse the repository at this point in the history
  • Loading branch information
ctz committed Jan 30, 2025
1 parent 200d566 commit 784b873
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions rustls/src/vecbuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ impl ChunkVecBuffer {
let len = bytes.len();

if !bytes.is_empty() {
if self.chunks.is_empty() {
debug_assert_eq!(self.prefix_used, 0);
}

self.chunks.push_back(bytes);
}

Expand Down Expand Up @@ -190,6 +194,7 @@ impl ChunkVecBuffer {
}
let len = cmp::min(bufs.len(), self.chunks.len());
let used = wr.write_vectored(&bufs[..len])?;
assert!(used <= self.len(), "illegal write_vectored return value");
self.consume(used);
Ok(used)
}
Expand Down

0 comments on commit 784b873

Please sign in to comment.