From b04bc7d7b065caec285b6c5a0646d3b8efed9aed Mon Sep 17 00:00:00 2001 From: Charles Dang Date: Tue, 6 Feb 2018 01:10:36 +1100 Subject: [PATCH] Minimap: fixed UB when accessing display singleton (fixes #2447) Was UB when drawing the minimap in the editor since the display object was an editor_disply not game_display. No reason to access game_display anyway, since is_blindfolded() is defined in display. Cropped up in 786233d5c95913889d6f061f3749f80a5efd61c1. --- src/minimap.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/minimap.cpp b/src/minimap.cpp index 4b85e2fc9bb3..305494041c5a 100644 --- a/src/minimap.cpp +++ b/src/minimap.cpp @@ -16,22 +16,20 @@ #include "minimap.hpp" +#include "color.hpp" +#include "display.hpp" +#include "formula/string_utils.hpp" #include "game_board.hpp" #include "gettext.hpp" #include "image.hpp" #include "log.hpp" #include "map/map.hpp" +#include "preferences/general.hpp" #include "resources.hpp" -#include "color.hpp" #include "sdl/surface.hpp" #include "team.hpp" #include "terrain/type_data.hpp" #include "wml_exception.hpp" -#include "formula/string_utils.hpp" - -#include "game_display.hpp" - -#include "preferences/general.hpp" static lg::log_domain log_display("display"); #define DBG_DP LOG_STREAM(debug, log_display) @@ -84,7 +82,7 @@ surface getMinimap(int w, int h, const gamemap &map, const team *vw, const std:: if(!map.on_board_with_border(loc)) continue; - const bool shrouded = (game_display::get_singleton() != nullptr && game_display::get_singleton()->is_blindfolded()) || (vw != nullptr && vw->shrouded(loc)); + const bool shrouded = (display::get_singleton() != nullptr && display::get_singleton()->is_blindfolded()) || (vw != nullptr && vw->shrouded(loc)); // shrouded hex are not considered fogged (no need to fog a black image) const bool fogged = (vw != nullptr && !shrouded && vw->fogged(loc));