diff --git a/lib/synergy/CKeyState.cpp b/lib/synergy/CKeyState.cpp index 5dffa9d0..89e2001c 100644 --- a/lib/synergy/CKeyState.cpp +++ b/lib/synergy/CKeyState.cpp @@ -374,19 +374,21 @@ CKeyState::isModifierActive(KeyModifierMask mask) const { const KeyButtons& buttons = m_maskToKeys[getIndexForModifier(mask)]; KeyButtons::const_iterator j = buttons.begin(); - if (isToggle(mask)) { - // modifier is a toggle - if ((m_keys[*j] & kToggled) != 0) { - return true; - } - } - else { - // modifier is not a toggle - for (; j != buttons.end(); ++j) { - if ((m_keys[*j] & kDown) != 0) { + if (j != buttons.end()) { + if (isToggle(mask)) { + // modifier is a toggle + if ((m_keys[*j] & kToggled) != 0) { return true; } } + else { + // modifier is not a toggle + for (; j != buttons.end(); ++j) { + if ((m_keys[*j] & kDown) != 0) { + return true; + } + } + } } return false; }