Skip to content

Commit

Permalink
Fix a layout miscalculation in alloc::RawVec
Browse files Browse the repository at this point in the history
  • Loading branch information
a1phyr committed Feb 12, 2022
1 parent 9cdefd7 commit 6027182
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions library/alloc/src/raw_vec.rs
Expand Up @@ -244,9 +244,7 @@ impl<T, A: Allocator> RawVec<T, A> {
// We have an allocated chunk of memory, so we can bypass runtime
// checks to get our current layout.
unsafe {
let align = mem::align_of::<T>();
let size = mem::size_of::<T>() * self.cap;
let layout = Layout::from_size_align_unchecked(size, align);
let layout = Layout::array::<T>(self.cap).unwrap_unchecked();
Some((self.ptr.cast().into(), layout))
}
}
Expand Down

0 comments on commit 6027182

Please sign in to comment.