From 429515482fa4fa951fd4a3cdd3fceb78ab775a1b Mon Sep 17 00:00:00 2001 From: Bill Lash Date: Wed, 2 Oct 2019 18:42:24 -0500 Subject: [PATCH] Cap the maximum indexes into image Make sure not to index past the right and/or bottom edge of the image while scaling. --- src/sdl/sf_video.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/sdl/sf_video.c b/src/sdl/sf_video.c index 135ef1d..c056929 100644 --- a/src/sdl/sf_video.c +++ b/src/sdl/sf_video.c @@ -601,8 +601,12 @@ void os_draw_picture(int picture, int y, int x) for (yy = 0; yy < eh * m_gfxScale_h; yy++) { int ys = ceil(yy / m_gfxScale_h); + if (ys >= pic->height) + ys = pic->height - 1; for (xx = 0; xx < ew * m_gfxScale_w; xx++) { int xs = ceil(xx / m_gfxScale_w); + if (xs >= pic->width) + xs = pic->width - 1; int index = pic->pixels[ys * pic->width + xs]; if (index != pic->transparentcolor) sf_wpixel(x + xx, y + yy, -- 2.34.1