From 400c25c653549b236d701d6b0d9b47a9565ec5be Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Wed, 13 Jun 2018 21:21:49 +0200 Subject: [PATCH] fixed bug causing crash when trying to draw undefined optional graphics Before, the program crashed (segmentation fault) if optional graphics (like "menu.button_level_number", which are defined to be off-screen by default) are defined to a valid screen position (by setting the corresponding screen position values like "main.button.level_number.x/y" to positions on the screen), but no image was defined to be used for that graphic. This bug was fixed by using fallback graphics when attempting to draw those undefined optional graphics. --- src/tools.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/tools.c b/src/tools.c index 76b40a29..6d3a0aeb 100644 --- a/src/tools.c +++ b/src/tools.c @@ -1574,6 +1574,10 @@ void getSizedGraphicSourceExt(int graphic, int frame, int tilesize, { struct GraphicInfo *g = &graphic_info[graphic]; + // if no graphics defined at all, use fallback graphics + if (g->bitmaps == NULL) + *g = graphic_info[IMG_CHAR_EXCLAM]; + // if no in-game graphics defined, always use standard graphic size if (g->bitmaps[IMG_BITMAP_GAME] == NULL) tilesize = TILESIZE; -- 2.34.1