You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- RawVecInner::grow_exact causes UB if called with len and additional
arguments such that len + additional is less than the current
capacity. Indeed, in that case it calls Allocator::grow with a
new_layout that is smaller than old_layout, which violates a safety
precondition.
- RawVecInner::grow_exact and RawVecInner::grow_amortized both cause UB
if called with an elem_layout different from the one used to initially
allocate the buffer, because in that case Allocator::grow is called with
an old_layout that does not fit the allocated block, which violates a
safety precondition.
- Since RawVecInner::try_reserve and RawVecInner::try_reserve_exact call
RawVecInner::grow_amortized and RawVecInner::grow_exact, they also cause
UB if called with an elem_layout different from the one used to
initially allocate the buffer.
- Furthermore, these methods cause UB if called with an elem_layout
where the size is not a multiple of the alignment. This is because
Layout::repeat is used (in layout_array) to compute the allocation's
layout when allocating, which includes padding to ensure alignment of
array elements, but simple multiplication is used (in current_memory) to
compute the old allocation's layout when resizing or deallocating, which
would cause the layout used to resize or deallocate to not fit the
allocated block, which violates a safety precondition.
0 commit comments