aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/memline.c
diff options
context:
space:
mode:
authorJan Edmund Lazo <janedmundlazo@hotmail.com>2018-09-16 20:28:05 -0400
committerJan Edmund Lazo <janedmundlazo@hotmail.com>2018-09-16 20:46:06 -0400
commit91352b36b70ef20a4d1b94c4160129bf5f0d6b60 (patch)
treeb962dbc4ea8c42dec2e8fc7a7888c58f47cda33f /src/nvim/memline.c
parent9f1401e25cfcd3db1ccb4471599e13c5e5c3e5d8 (diff)
downloadrneovim-91352b36b70ef20a4d1b94c4160129bf5f0d6b60.tar.gz
rneovim-91352b36b70ef20a4d1b94c4160129bf5f0d6b60.tar.bz2
rneovim-91352b36b70ef20a4d1b94c4160129bf5f0d6b60.zip
vim-patch:8.0.1416: crash when searching for a sentence
Problem: Crash when searching for a sentence. Solution: Return NUL when getting character at MAXCOL. (closes vim/vim#2468) https://github.com/vim/vim/commit/8ada6aa9298b4764d9ca0024dd21b17e815595ce
Diffstat (limited to 'src/nvim/memline.c')
-rw-r--r--src/nvim/memline.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/nvim/memline.c b/src/nvim/memline.c
index ec9996810f..a787e2f104 100644
--- a/src/nvim/memline.c
+++ b/src/nvim/memline.c
@@ -3999,18 +3999,15 @@ void goto_byte(long cnt)
/// Return 0 otherwise.
int inc(pos_T *lp)
{
- char_u *p = ml_get_pos(lp);
-
- if (*p != NUL) { // still within line, move to next char (may be NUL)
- if (has_mbyte) {
- int l = (*mb_ptr2len)(p);
+ // when searching position may be set to end of a line
+ if (lp->col != MAXCOL) {
+ const char_u *const p = ml_get_pos(lp);
+ if (*p != NUL) { // still within line, move to next char (may be NUL)
+ const int l = utfc_ptr2len(p);
lp->col += l;
- return (p[l] != NUL) ? 0 : 2;
+ return ((p[l] != NUL) ? 0 : 2);
}
- lp->col++;
- lp->coladd = 0;
- return (p[1] != NUL) ? 0 : 2;
}
if (lp->lnum != curbuf->b_ml.ml_line_count) { // there is a next line
lp->col = 0;