summaryrefslogtreecommitdiffstats
path: root/src/getchar.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-04-27 11:58:01 +0100
committerBram Moolenaar <Bram@vim.org>2022-04-27 11:58:01 +0100
commit12e21e387b5bbc928097abf1c189b7dc665838fc (patch)
tree71ec4c8aa2bb205ec22780ba1ed687b17f600287 /src/getchar.c
parentfc78a0369e0d371a1a85d07045ff25d8695e8f8c (diff)
patch 8.2.4833: failure of mapping not checked forv8.2.4833
Problem: Failure of mapping not checked for. Solution: Check return value of ins_typebuf(). (closes #10299)
Diffstat (limited to 'src/getchar.c')
-rw-r--r--src/getchar.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/getchar.c b/src/getchar.c
index e208dd1a18..e6879c60d9 100644
--- a/src/getchar.c
+++ b/src/getchar.c
@@ -2363,7 +2363,7 @@ at_ctrl_x_key(void)
* into just a key, apply that.
* Check from typebuf.tb_buf[typebuf.tb_off] to typebuf.tb_buf[typebuf.tb_off
* + "max_offset"].
- * Return the length of the replaced bytes, zero if nothing changed.
+ * Return the length of the replaced bytes, 0 if nothing changed, -1 for error.
*/
static int
check_simplify_modifier(int max_offset)
@@ -2397,7 +2397,15 @@ check_simplify_modifier(int max_offset)
vgetc_char = c;
vgetc_mod_mask = tp[2];
}
- len = mb_char2bytes(new_c, new_string);
+ if (IS_SPECIAL(new_c))
+ {
+ new_string[0] = K_SPECIAL;
+ new_string[1] = K_SECOND(new_c);
+ new_string[2] = K_THIRD(new_c);
+ len = 3;
+ }
+ else
+ len = mb_char2bytes(new_c, new_string);
if (modifier == 0)
{
if (put_string_in_typebuf(offset, 4, new_string, len,
@@ -2424,6 +2432,7 @@ check_simplify_modifier(int max_offset)
* - When nothing mapped and typeahead has a character: return map_result_get.
* - When there is no match yet, return map_result_nomatch, need to get more
* typeahead.
+ * - On failure (out of memory) return map_result_fail.
*/
static int
handle_mapping(
@@ -2706,7 +2715,12 @@ handle_mapping(
// If no termcode matched, try to include the modifier into the
// key. This is for when modifyOtherKeys is working.
if (keylen == 0 && !no_reduce_keys)
+ {
keylen = check_simplify_modifier(max_mlen + 1);
+ if (keylen < 0)
+ // ins_typebuf() failed
+ return map_result_fail;
+ }
// When getting a partial match, but the last characters were not
// typed, don't wait for a typed character to complete the