fixed potential crash bug (accessing invalid memory)
[rocksndiamonds.git] / src / tools.c
index 459f85a769cf82263a4229a219130bcc973461af..33b677954947107346e76e69d65f778027d1e2f6 100644 (file)
@@ -1150,10 +1150,12 @@ void FadeSkipNextFadeOut(void)
 
 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);
 }