Skip to content

Commit 9133798

Browse files
authored
Rollup merge of rust-lang#56648 - RalfJung:btree, r=sfackler
Fix BTreeMap UB BTreeMap currently causes UB by created a shared reference to a too-small allocation. This PR fixes that by introducing a `NodeHeader` type and using that until we really need access to the key/value arrays. Avoiding run-time checks in `into_key_slice` was somewhat tricky, see the comments embedded in the code. I also adjusted `as_leaf_mut` to return a raw pointer, because creating a mutable reference asserts that there are no aliases to the pointee, but that's not always correct: We use `as_leaf_mut` twice to create two mutable slices for keys and values; the second call overlaps with the first slice and hence is not a unique pointer. Fixes rust-lang#54957 Cc @nikomatsakis @gankro
2 parents 32f922e + d9c64e5 commit 9133798

File tree

1 file changed

+117
-57
lines changed
  • src/liballoc/collections/btree

1 file changed

+117
-57
lines changed

0 commit comments

Comments
 (0)