diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-09-05 14:10:32 -0700 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2019-09-05 14:10:32 -0700 |
commit | 8b06231612cd608b2dce5e0a09bf40192a4803cb (patch) | |
tree | 04fbfef7b326574e296b2fe1a772829ac0af8be4 /src/nvim/keymap.c | |
parent | 096212d52c6375c19c046d86a7178bae91e287fc (diff) | |
parent | d3f1eb3024fa297c970a79dd24ef818e4aeb8525 (diff) | |
download | rneovim-8b06231612cd608b2dce5e0a09bf40192a4803cb.tar.gz rneovim-8b06231612cd608b2dce5e0a09bf40192a4803cb.tar.bz2 rneovim-8b06231612cd608b2dce5e0a09bf40192a4803cb.zip |
Merge #10869 'vim-patch:8.1.{0309,0362,0365,0515,1946}'
Diffstat (limited to 'src/nvim/keymap.c')
-rw-r--r-- | src/nvim/keymap.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/nvim/keymap.c b/src/nvim/keymap.c index eab65f2625..b8b9c945b9 100644 --- a/src/nvim/keymap.c +++ b/src/nvim/keymap.c @@ -824,7 +824,8 @@ char_u *replace_termcodes(const char_u *from, const size_t from_len, // Allocate space for the translation. Worst case a single character is // replaced by 6 bytes (shifted special key), plus a NUL at the end. - result = xmalloc(from_len * 6 + 1); + const size_t buf_len = from_len * 6 + 1; + result = xmalloc(buf_len); src = from; @@ -849,14 +850,15 @@ char_u *replace_termcodes(const char_u *from, const size_t from_len, // Replace <SID> by K_SNR <script-nr> _. // (room: 5 * 6 = 30 bytes; needed: 3 + <nr> + 1 <= 14) if (end - src >= 4 && STRNICMP(src, "<SID>", 5) == 0) { - if (current_SID <= 0) { + if (current_sctx.sc_sid <= 0) { EMSG(_(e_usingsid)); } else { src += 5; result[dlen++] = K_SPECIAL; result[dlen++] = (int)KS_EXTRA; result[dlen++] = (int)KE_SNR; - sprintf((char *)result + dlen, "%" PRId64, (int64_t)current_SID); + snprintf((char *)result + dlen, buf_len - dlen, "%" PRId64, + (int64_t)current_sctx.sc_sid); dlen += STRLEN(result + dlen); result[dlen++] = '_'; continue; |