x11: Assert that size >= buffer_size

This commit is contained in:
Luna 2023-04-24 20:31:39 -03:00
parent c68f41bf10
commit 5efa5d8898

View file

@ -540,6 +540,8 @@ struct ShmSegment {
impl ShmSegment {
/// Create a new `ShmSegment` with the given size.
fn new(size: usize, buffer_size: usize) -> io::Result<Self> {
assert!(size >= buffer_size);
unsafe {
// Create the shared memory segment.
let id = shmget(IPC_PRIVATE, size, 0o600);
@ -588,6 +590,7 @@ impl ShmSegment {
/// Set the size of the buffer for this shared memory segment.
fn set_buffer_size(&mut self, buffer_size: usize) {
assert!(self.size >= buffer_size);
self.buffer_size = buffer_size
}