From 610518104b9189fcd5a16ca77a78874c6d99f2d8 Mon Sep 17 00:00:00 2001 From: crs Date: Tue, 30 Mar 2004 18:55:58 +0000 Subject: [PATCH] Fixed crash bug in CKeyState. Would deference bogus pointer in isModifierActive if there's an unmapped toggle modifier. --- lib/synergy/CKeyState.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/synergy/CKeyState.cpp b/lib/synergy/CKeyState.cpp index 5dffa9d0b..89e2001c9 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; }