From 0a2c43af8811fecf6fd08379f16571594bcbb738 Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Thu, 28 Apr 2022 19:37:33 +1000 Subject: Fix bugs in `BytesMut::reserve_inner` (#544) --- src/bytes_mut.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') 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. -- cgit v1.2.3