From 8fe5772614b88c44ecfba69086459a76a7b1cf30 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Tue, 8 Feb 2022 17:05:47 +0100 Subject: [PATCH] fixed crash bug caused by accessing invalid (off-playfield) array positions This bug caused accessing array "GfxFrame[][]" out of bounds if level position is not inside the playfield. (This is always the case when invoked from "DrawScreenElementExt()" for level border elements. --- src/tools.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/tools.c b/src/tools.c index 6a998afb..9fe777c9 100644 --- a/src/tools.c +++ b/src/tools.c @@ -1506,7 +1506,9 @@ int getGraphicAnimationFrameXY(int graphic, int lx, int ly) return sync_frame % g->anim_frames; } - return getGraphicAnimationFrame(graphic, GfxFrame[lx][ly]); + int sync_frame = (IN_LEV_FIELD(lx, ly) ? GfxFrame[lx][ly] : -1); + + return getGraphicAnimationFrame(graphic, sync_frame); } void getGraphicSourceBitmap(int graphic, int tilesize, Bitmap **bitmap) -- 2.34.1