diff --git a/src/editline.c b/src/editline.c index 890b5aa..e9e1e67 100644 --- a/src/editline.c +++ b/src/editline.c @@ -1701,7 +1701,7 @@ static el_status_t el_bind_key_in_map(int key, el_keymap_func_t function, el_key /* Must check that pos is not the next to last array position, * otherwise we will write out-of-bounds to terminate the list. */ - if (pos >= mapsz - 1) { + if (pos + 1 >= mapsz) { errno = ENOMEM; return CSeof; } @@ -1710,8 +1710,8 @@ static el_status_t el_bind_key_in_map(int key, el_keymap_func_t function, el_key creat = map[pos].Function == NULL; /* A new key so have to add it to end */ - map[pos].Key = key; - map[pos].Function = function; + map[pos].Key = key; + map[pos].Function = function; /* Terminate list */ if (creat) {