Added safety checks for incorrectly sized buffers being passed

This commit is contained in:
David Johnson 2022-01-16 08:07:39 -06:00
parent d89a0c92aa
commit 8286c2bd6c
2 changed files with 46 additions and 0 deletions

View file

@ -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);
}