driver: display: Added extra asserts to SDL display
Added extra asserts to write function of SDL display driver to check if write is within bounds. Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
This commit is contained in:
parent
814f94e053
commit
adecdd5d43
1 changed files with 14 additions and 0 deletions
|
@ -225,6 +225,20 @@ static int sdl_display_write(const struct device *dev, const uint16_t x,
|
|||
desc->height, x, y);
|
||||
|
||||
__ASSERT(desc->width <= desc->pitch, "Pitch is smaller then width");
|
||||
__ASSERT(desc->pitch <= CONFIG_SDL_DISPLAY_X_RES,
|
||||
"Pitch in descriptor is larger than screen size");
|
||||
__ASSERT(desc->height <= CONFIG_SDL_DISPLAY_Y_RES,
|
||||
"Height in descriptor is larger than screen size");
|
||||
__ASSERT(x + desc->pitch <= CONFIG_SDL_DISPLAY_X_RES,
|
||||
"Writing outside screen boundaries in horizontal direction");
|
||||
__ASSERT(y + desc->height <= CONFIG_SDL_DISPLAY_Y_RES,
|
||||
"Writing outside screen boundaries in vertical direction");
|
||||
|
||||
if (desc->width > desc->pitch ||
|
||||
x + desc->pitch > CONFIG_SDL_DISPLAY_X_RES ||
|
||||
y + desc->height > CONFIG_SDL_DISPLAY_Y_RES) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (disp_data->current_pixel_format == PIXEL_FORMAT_ARGB_8888) {
|
||||
sdl_display_write_argb8888(disp_data->buf, desc, buf);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue