aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/grid.c
diff options
context:
space:
mode:
authorVanaIgr <vanaigranov@gmail.com>2024-02-26 04:12:55 -0600
committerGitHub <noreply@github.com>2024-02-26 18:12:55 +0800
commitad5a155b1f4b387d3aaa54c91d0146cb0287bb9f (patch)
treeae35dff22d4f418f040d39acc88206e64ffb1984 /src/nvim/grid.c
parent8b4e26915612caf2d143edca31919cae18a848a1 (diff)
downloadrneovim-ad5a155b1f4b387d3aaa54c91d0146cb0287bb9f.tar.gz
rneovim-ad5a155b1f4b387d3aaa54c91d0146cb0287bb9f.tar.bz2
rneovim-ad5a155b1f4b387d3aaa54c91d0146cb0287bb9f.zip
fix(mbyte): fix bugs in utf_cp_*_off() functions
Problems: - Illegal bytes after valid UTF-8 char cause utf_cp_*_off() to fail. - When stream isn't NUL-terminated, utf_cp_*_off() may go over the end. Solution: Don't go over end of the char of end of the string.
Diffstat (limited to 'src/nvim/grid.c')
-rw-r--r--src/nvim/grid.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/nvim/grid.c b/src/nvim/grid.c
index b6a8a8bd9f..e386853022 100644
--- a/src/nvim/grid.c
+++ b/src/nvim/grid.c
@@ -277,7 +277,7 @@ void line_do_arabic_shape(schar_T *buf, int cols)
// Too bigly, discard one code-point.
// This should be enough as c0 cannot grow more than from 2 to 4 bytes
// (base arabic to extended arabic)
- rest -= (size_t)utf_cp_head_off(scbuf + off, scbuf + off + rest - 1) + 1;
+ rest -= (size_t)utf_cp_bounds(scbuf + off, scbuf + off + rest - 1).begin_off + 1;
}
memcpy(scbuf_new + len, scbuf + off, rest);
buf[i] = schar_from_buf(scbuf_new, len + rest);