From f2caaad78efa7d7381c7dd4ed3757191ab255b2e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 7 Jan 2024 14:59:20 -0500 Subject: [PATCH] [Backport release-0.9] fix(tui): use buflen to calculate remaining buffer size (#26943) fix(tui): use buflen to calculate remaining buffer size (#26942) buf is a pointer argument, not a local char array, so sizeof(buf) is just the size of a pointer type on the platform. This is always an incorrect value, but on 32-bit platforms it actually has an impact, since sizeof(buf) is just 4 and causes the buffer to get truncated. (cherry picked from commit 367e52cc79a786bbee4456b30f9ec5db7e28d6a5) Co-authored-by: James McCoy --- src/nvim/tui/input.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/nvim/tui/input.c b/src/nvim/tui/input.c index 6280c48059..743f8940c7 100644 --- a/src/nvim/tui/input.c +++ b/src/nvim/tui/input.c @@ -237,13 +237,13 @@ static size_t handle_termkey_modifiers(TermKeyKey *key, char *buf, size_t buflen { size_t len = 0; if (key->modifiers & TERMKEY_KEYMOD_SHIFT) { // Shift - len += (size_t)snprintf(buf + len, sizeof(buf) - len, "S-"); + len += (size_t)snprintf(buf + len, buflen - len, "S-"); } if (key->modifiers & TERMKEY_KEYMOD_ALT) { // Alt - len += (size_t)snprintf(buf + len, sizeof(buf) - len, "A-"); + len += (size_t)snprintf(buf + len, buflen - len, "A-"); } if (key->modifiers & TERMKEY_KEYMOD_CTRL) { // Ctrl - len += (size_t)snprintf(buf + len, sizeof(buf) - len, "C-"); + len += (size_t)snprintf(buf + len, buflen - len, "C-"); } assert(len < buflen); return len;