-
Couldn't load subscription status.
- Fork 91
Description
For given buffer, canvas = SlotPool::create_buffer(..), canvas might be bigger than the one returned from buffer.canvas(). This happens because of buffer alignment at the allocation:
client-toolkit/src/shm/slot.rs
Line 257 in 4cf0def
| len = (len + 63) & !63; |
for the Buffer::canvas it explicitly limits the canvas by height*stride as expected:
client-toolkit/src/shm/slot.rs
Lines 425 to 430 in 4cf0def
| let len = (self.height as usize) * (self.stride as usize); | |
| if self.slot.inner.active_buffers.load(Ordering::Relaxed) != 0 { | |
| return None; | |
| } | |
| if self.slot.inner.free_list.as_ptr() == Arc::as_ptr(&pool.free_list) { | |
| Some(&mut pool.inner.mmap()[self.slot.inner.offset..][..len]) |
while the Slot::raw_data_mut inside create_buffer has only a bound of the allocated slot:
client-toolkit/src/shm/slot.rs
Line 279 in 4cf0def
| &mut self.inner.mmap()[slot.inner.offset..][..slot.inner.len] |
This implementation is fine if documented. Although I would rather prefer these two to be the same without exposing inner stuff. Also, is SlotPool::raw_data_mut really sound considering aliasing?