diff options
author | Matthew Malcomson <hardenedapple@gmail.com> | 2017-01-27 12:09:33 +0000 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2017-03-07 01:29:08 +0100 |
commit | 6fe677c108c9a84be998a9355ae9700348cb0cc5 (patch) | |
tree | 77d275fc46f1b59e61c19a8a578698fae2673e43 /test/functional/api/buffer_spec.lua | |
parent | 1215084676f0d0372da5337ab81707f62748bb1f (diff) | |
download | rneovim-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 'test/functional/api/buffer_spec.lua')
-rw-r--r-- | test/functional/api/buffer_spec.lua | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/functional/api/buffer_spec.lua b/test/functional/api/buffer_spec.lua index e7e2168238..552e3a8564 100644 --- a/test/functional/api/buffer_spec.lua +++ b/test/functional/api/buffer_spec.lua @@ -4,6 +4,9 @@ local curbuf, curwin, eq = helpers.curbuf, helpers.curwin, helpers.eq local curbufmeths, ok = helpers.curbufmeths, helpers.ok local funcs = helpers.funcs local request = helpers.request +local exc_exec = helpers.exc_exec +local execute = helpers.execute +local insert = helpers.insert local NIL = helpers.NIL local meth_pcall = helpers.meth_pcall local command = helpers.command @@ -242,6 +245,22 @@ describe('api/buf', function() eq({'e', 'a', 'b', 'c', 'd'}, get_lines(0, -1, true)) end) + it("set_line on alternate buffer does not access invalid line (E315)", function() + execute('set hidden') + insert('Initial file') + command('enew') + insert([[ + More + Lines + Than + In + The + Other + Buffer]]) + execute('$') + local retval = exc_exec("call nvim_buf_set_lines(1, 0, 1, v:false, ['test'])") + eq(0, retval) + end) end) describe('{get,set,del}_var', function() |