diff --git a/src/keytables.cc b/src/keytables.cc index 2ec5dad..94b139b 100644 --- a/src/keytables.cc +++ b/src/keytables.cc @@ -40,19 +40,19 @@ const char char_or_func[] = // c = character key, f = function key, _ = blank/e inline bool is_char_key(unsigned int code) { - assert(code < sizeof(char_or_func)); + assert(code < sizeof(char_or_func)-1); return (char_or_func[code] == 'c'); } inline bool is_func_key(unsigned int code) { - assert(code < sizeof(char_or_func)); + assert(code < sizeof(char_or_func)-1); return (char_or_func[code] == 'f'); } inline bool is_used_key(unsigned int code) { - assert(code < sizeof(char_or_func)); + assert(code < sizeof(char_or_func)-1); return (char_or_func[code] != '_'); } diff --git a/src/logkeys.cc b/src/logkeys.cc index 5da3cff..63c1a21 100644 --- a/src/logkeys.cc +++ b/src/logkeys.cc @@ -189,7 +189,7 @@ void determine_system_keymap() std::stringstream ss, dump(execute(COMMAND_STR_DUMPKEYS)); // see example output after i.e. `loadkeys slovene` std::string line; - unsigned int i = 0; // keycode + unsigned int i = -1; // keycode int index; int utf8code; // utf-8 code of keysym answering keycode i @@ -205,7 +205,7 @@ void determine_system_keymap() index = line.find("U+", index); } - if (++i >= sizeof(char_or_func)) break; // only ever map keycodes up to 128 (currently N_KEYS_DEFINED are used) + if (++i >= sizeof(char_or_func)-1) break; // only ever map keycodes up to 128 (currently N_KEYS_DEFINED are used) if (!is_char_key(i)) continue; // only map character keys of keyboard assert(line.size() > 0);