From 91352b36b70ef20a4d1b94c4160129bf5f0d6b60 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 16 Sep 2018 20:28:05 -0400 Subject: 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 --- src/nvim/ex_docmd.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/nvim/ex_docmd.c') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index ac5de0733b..7c0e2afb0b 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -3665,13 +3665,14 @@ static linenr_T get_address(exarg_T *eap, if (lnum != MAXLNUM) curwin->w_cursor.lnum = lnum; /* - * Start a forward search at the end of the line. + * Start a forward search at the end of the line (unless + * before the first line). * Start a backward search at the start of the line. * This makes sure we never match in the current * line, and can match anywhere in the * next/previous line. */ - if (c == '/') + if (c == '/' && curwin->w_cursor.lnum > 0) curwin->w_cursor.col = MAXCOL; else curwin->w_cursor.col = 0; -- cgit From a0ada7dac496de46aff416505d536c78fea80524 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 16 Sep 2018 20:55:59 -0400 Subject: lint --- src/nvim/ex_docmd.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/nvim/ex_docmd.c') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 7c0e2afb0b..e4ab690bb9 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -3664,18 +3664,18 @@ static linenr_T get_address(exarg_T *eap, */ if (lnum != MAXLNUM) curwin->w_cursor.lnum = lnum; - /* - * Start a forward search at the end of the line (unless - * before the first line). - * Start a backward search at the start of the line. - * This makes sure we never match in the current - * line, and can match anywhere in the - * next/previous line. - */ - if (c == '/' && curwin->w_cursor.lnum > 0) + + // Start a forward search at the end of the line (unless + // before the first line). + // Start a backward search at the start of the line. + // This makes sure we never match in the current + // line, and can match anywhere in the + // next/previous line. + if (c == '/' && curwin->w_cursor.lnum > 0) { curwin->w_cursor.col = MAXCOL; - else + } else { curwin->w_cursor.col = 0; + } searchcmdlen = 0; if (!do_search(NULL, c, cmd, 1L, SEARCH_HIS | SEARCH_MSG, NULL)) { -- cgit