Skip to content

Commit

Permalink
fix a segfault
Browse files Browse the repository at this point in the history
scope_active_.size() = SCOPE_COUNT, so scope_active_[SCOPE_COUNT] is
undefined behaviour.

it seems like in add_hotkey it can happen that
hotkey::get_hotkey_command(item.get_command()).scope return SCOPE_COUNT
for wml hotkeys
  • Loading branch information
gfgtdf committed Jun 18, 2014
1 parent d5cc615 commit 0ac8508
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/hotkey/hotkey_command.cpp
Expand Up @@ -293,6 +293,8 @@ void set_scope_active(scope s, bool set)

bool is_scope_active(scope s)
{
if( s == hotkey::SCOPE_COUNT )
return false;
return scope_active_[s];
}

Expand Down
2 changes: 2 additions & 0 deletions src/hotkey/hotkey_item.cpp
Expand Up @@ -236,6 +236,8 @@ bool has_hotkey_item(const std::string& command)
void add_hotkey(const hotkey_item& item) {

scope new_scope = hotkey::get_hotkey_command(item.get_command()).scope;
if(new_scope == hotkey::SCOPE_COUNT)
new_scope = hotkey::SCOPE_GAME;
scope_changer scope_ch;
deactivate_all_scopes();
hotkey::set_scope_active(new_scope);
Expand Down

0 comments on commit 0ac8508

Please sign in to comment.