This change fixes a bug that occured when invoking the changed
function with a "graphic" parameter indicating undefined graphic,
which is defined as "-1" and caused an "array out of bounds" access.
To fix this bug, the function parameter is checked before used.
static Bitmap *getBitmapFromGraphicOrDefault(int graphic, int default_graphic)
{
+ if (graphic == IMG_UNDEFINED)
+ return NULL;
+
boolean redefined = getImageListEntryFromImageID(graphic)->redefined;
- return (graphic == IMG_UNDEFINED ? NULL :
- graphic_info[graphic].bitmap != NULL || redefined ?
+ return (graphic_info[graphic].bitmap != NULL || redefined ?
graphic_info[graphic].bitmap :
graphic_info[default_graphic].bitmap);
}