From 6fe677c108c9a84be998a9355ae9700348cb0cc5 Mon Sep 17 00:00:00 2001 From: Matthew Malcomson Date: Fri, 27 Jan 2017 12:09:33 +0000 Subject: api: nvim_buf_set_lines(): Avoid invalid ml_get. #6019 When the buffer that nvim_buf_set_lines() is changing is not in any vim window, fix_cursor() leads to calling ml_get_buf() with an invalid line number. The condition that fix_cursor() was called on was (buf == curbuf), but this is always true because of the call to switch_to_win_for_buf() earlier in the function. Instead this should be predicated on (save_curbuf.br_buf == NULL) --- src/nvim/api/buffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/api/buffer.c') diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c index c667732f7d..c7e535228a 100644 --- a/src/nvim/api/buffer.c +++ b/src/nvim/api/buffer.c @@ -395,7 +395,7 @@ void nvim_buf_set_lines(uint64_t channel_id, changed_lines((linenr_T)start, 0, (linenr_T)end, extra); - if (buf == curbuf) { + if (save_curbuf.br_buf == NULL) { fix_cursor((linenr_T)start, (linenr_T)end, extra); } -- cgit