patch 8.1.0242: Insert mode completion may use an invalid buffer pointer
Problem: Insert mode completion may use an invalid buffer pointer.
Solution: Check for ins_buf to be valid. (closes #3290)
diff --git a/src/edit.c b/src/edit.c
index daadc7b..45176d7 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -4419,10 +4419,15 @@
? (char_u *)"." : curbuf->b_p_cpt;
last_match_pos = first_match_pos = *ini;
}
+ else if (ins_buf != curbuf && !buf_valid(ins_buf))
+ ins_buf = curbuf; // In case the buffer was wiped out.
compl_old_match = compl_curr_match; /* remember the last current match */
pos = (compl_direction == FORWARD) ? &last_match_pos : &first_match_pos;
- /* For ^N/^P loop over all the flags/windows/buffers in 'complete' */
+
+ /*
+ * For ^N/^P loop over all the flags/windows/buffers in 'complete'.
+ */
for (;;)
{
found_new_match = FAIL;