about summary refs log tree commit diff
path: root/src/librustc_middle/ty
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2020-06-16 15:08:35 +0200
committerGitHub <noreply@github.com>2020-06-16 15:08:35 +0200
commitc65f39dac4114052eee2a900a287d767d8b678c6 (patch)
tree09c64fc7b41ffb71c1f656783ef84a976acb677b /src/librustc_middle/ty
parentc8a9c340de32cb70c8bad8af1a4474f805c5a969 (diff)
parent1f0895162ba5a783d4d73d5c263552eaca9343b3 (diff)
downloadrust-c65f39dac4114052eee2a900a287d767d8b678c6.tar.gz
rust-c65f39dac4114052eee2a900a287d767d8b678c6.zip
Rollup merge of #73237 - tmiasko:arena, r=nnethercote
Check for overflow in DroplessArena and align returned memory

* Check for overflow when calculating the slice start & end position.
* Align the pointer obtained from the allocator, ensuring that it
  satisfies user requested alignment (the allocator is only asked for
  layout compatible with u8 slice).
* Remove an incorrect assertion from DroplessArena::align.
* Avoid forming references to an uninitialized memory in DroplessArena.

Helps with #73007, #72624.
Diffstat (limited to 'src/librustc_middle/ty')
-rw-r--r--src/librustc_middle/ty/list.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/librustc_middle/ty/list.rs b/src/librustc_middle/ty/list.rs
index 161783bb370..76c72e4c260 100644
--- a/src/librustc_middle/ty/list.rs
+++ b/src/librustc_middle/ty/list.rs
@@ -55,7 +55,7 @@ impl<T: Copy> List<T> {
             .dropless
             .alloc_raw(size, cmp::max(mem::align_of::<T>(), mem::align_of::<usize>()));
         unsafe {
-            let result = &mut *(mem.as_mut_ptr() as *mut List<T>);
+            let result = &mut *(mem as *mut List<T>);
             // Write the length
             result.len = slice.len();