aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/buffer.c
diff options
context:
space:
mode:
authorMatthew Malcomson <hardenedapple@gmail.com>2017-01-27 12:09:33 +0000
committerJustin M. Keyes <justinkz@gmail.com>2017-03-07 01:29:08 +0100
commit6fe677c108c9a84be998a9355ae9700348cb0cc5 (patch)
tree77d275fc46f1b59e61c19a8a578698fae2673e43 /src/nvim/api/buffer.c
parent1215084676f0d0372da5337ab81707f62748bb1f (diff)
downloadrneovim-6fe677c108c9a84be998a9355ae9700348cb0cc5.tar.gz
rneovim-6fe677c108c9a84be998a9355ae9700348cb0cc5.tar.bz2
rneovim-6fe677c108c9a84be998a9355ae9700348cb0cc5.zip
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)
Diffstat (limited to 'src/nvim/api/buffer.c')
-rw-r--r--src/nvim/api/buffer.c2
1 files changed, 1 insertions, 1 deletions
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);
}