Skip to content

Commit

Permalink
Minimap: fixed UB when accessing display singleton (fixes #2447)
Browse files Browse the repository at this point in the history
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 786233d.
  • Loading branch information
Vultraz committed Feb 5, 2018
1 parent d9d67f0 commit b04bc7d
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/minimap.cpp
Expand Up @@ -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)
Expand Down Expand Up @@ -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));

Expand Down

0 comments on commit b04bc7d

Please sign in to comment.