LibGfx: add bounds checking before set_pixel call in GIF decoder

This fixes a crash when a GIF frame extends beyond the limits of the
logical screen, causing writes past the end of the frame buffer
This commit is contained in:
Peter Nelson 2020-11-01 15:26:26 +00:00 committed by Andreas Kling
parent a28f29c82c
commit 5567408bab
Notes: sideshowbarker 2024-07-19 01:35:40 +09:00

View file

@ -355,7 +355,7 @@ static bool decode_frame(GIFLoadingContext& context, size_t frame_index)
int x = pixel_index % image.width + image.x;
int y = row + image.y;
if (!image.transparent || color != image.transparency_index) {
if (context.frame_buffer->rect().contains(x, y) && (!image.transparent || color != image.transparency_index)) {
context.frame_buffer->set_pixel(x, y, c);
}