aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Jiahao XU <Jiahao_XU@outlook.com> 2022-04-28 19:37:33 +1000
committerGravatar GitHub <noreply@github.com> 2022-04-28 11:37:33 +0200
commit0a2c43af8811fecf6fd08379f16571594bcbb738 (patch)
treee418ac9c5763d686ff119ce14c5395694742a9be /src
parent8198f9e28ebbf59760af25748d18d6a43260edf3 (diff)
downloadbytes-0a2c43af8811fecf6fd08379f16571594bcbb738.tar.gz
bytes-0a2c43af8811fecf6fd08379f16571594bcbb738.tar.zst
bytes-0a2c43af8811fecf6fd08379f16571594bcbb738.zip
Fix bugs in `BytesMut::reserve_inner` (#544)
Diffstat (limited to 'src')
-rw-r--r--src/bytes_mut.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/bytes_mut.rs b/src/bytes_mut.rs
index 88d7f00..cc1a3ba 100644
--- a/src/bytes_mut.rs
+++ b/src/bytes_mut.rs
@@ -646,7 +646,7 @@ impl BytesMut {
self.cap = v.capacity();
} else {
// calculate offset
- let off = v.capacity() - self.cap;
+ let off = (self.ptr.as_ptr() as usize) - (v.as_ptr() as usize);
// new_cap is calculated in terms of `BytesMut`, not the underlying
// `Vec`, so it does not take the offset into account.