Added safety checks for incorrectly sized buffers being passed
This commit is contained in:
parent
d89a0c92aa
commit
8286c2bd6c
2 changed files with 46 additions and 0 deletions
|
|
@ -40,6 +40,10 @@ impl<W: HasRawWindowHandle> GraphicsContext<W> {
|
|||
|
||||
#[inline]
|
||||
pub fn set_buffer(&mut self, buffer: &[u32], width: u16, height: u16){
|
||||
if (width as usize)*(height as usize) != buffer.len(){
|
||||
panic!("The size of the passed buffer is not the correct size. Its length must be exactly width*height.");
|
||||
}
|
||||
|
||||
unsafe {
|
||||
self.graphics_context_impl.set_buffer(buffer, width, height);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue