Skip to content

Commit bde20a5

Browse files
authored
Fix invalid pointer casting (#750)
`fl` has type of `&&CommonFreeListPageResource`. `fl as *const _ as *mut _` will first implicitly convert `fl` to `*const &CommonFreeListPageResource`, then to `*mut CommonFreeListPageResource`. The second conversion from `*const` to `*mut` is incorrect.
1 parent a272c23 commit bde20a5

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/util/heap/layout/map32.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,10 @@ impl Map for Map32 {
195195
for fl in self_mut.shared_fl_map.iter() {
196196
if let Some(fl) = fl {
197197
#[allow(clippy::cast_ref_to_mut)]
198-
let fl_mut: &mut CommonFreeListPageResource =
199-
unsafe { &mut *(fl as *const _ as *mut _) };
198+
let fl_mut: &mut CommonFreeListPageResource = unsafe {
199+
&mut *(*fl as *const CommonFreeListPageResource
200+
as *mut CommonFreeListPageResource)
201+
};
200202
fl_mut.resize_freelist(start_address);
201203
}
202204
}

0 commit comments

Comments
 (0)