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 #2468)
diff --git a/src/misc1.c b/src/misc1.c
index 4c691bb..2d635d6 100644
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -2650,8 +2650,12 @@
int
gchar_pos(pos_T *pos)
{
- char_u *ptr = ml_get_pos(pos);
+ char_u *ptr;
+ /* When searching columns is sometimes put at the end of a line. */
+ if (pos->col == MAXCOL)
+ return NUL;
+ ptr = ml_get_pos(pos);
#ifdef FEAT_MBYTE
if (has_mbyte)
return (*mb_ptr2char)(ptr);