From: Holger Schemel Date: Tue, 8 Feb 2022 16:05:47 +0000 (+0100) Subject: fixed crash bug caused by accessing invalid (off-playfield) array positions X-Git-Tag: 4.3.1.1~2 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=8fe5772614b88c44ecfba69086459a76a7b1cf30;hp=b71e46505e5e3dc2213e67124dd1d245ca7a2cbb;p=rocksndiamonds.git 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. --- 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)