Skip to content

Commit 5efa5d8

Browse files
author
Luna
committed
x11: Assert that size >= buffer_size
1 parent c68f41b commit 5efa5d8

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/x11.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,8 @@ struct ShmSegment {
540540
impl ShmSegment {
541541
/// Create a new `ShmSegment` with the given size.
542542
fn new(size: usize, buffer_size: usize) -> io::Result<Self> {
543+
assert!(size >= buffer_size);
544+
543545
unsafe {
544546
// Create the shared memory segment.
545547
let id = shmget(IPC_PRIVATE, size, 0o600);
@@ -588,6 +590,7 @@ impl ShmSegment {
588590

589591
/// Set the size of the buffer for this shared memory segment.
590592
fn set_buffer_size(&mut self, buffer_size: usize) {
593+
assert!(self.size >= buffer_size);
591594
self.buffer_size = buffer_size
592595
}
593596

0 commit comments

Comments
 (0)