diff options
author | Nick Hynes <nhynes@mit.edu> | 2015-06-16 20:07:03 -0400 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2015-07-11 18:18:25 -0400 |
commit | 7475c1c0f795912ea5a4613a23c4ef5a1d88c24d (patch) | |
tree | 50ff1939381743ad72c64116e349364a99f93042 /src/nvim/api/buffer.c | |
parent | 90b4276d67b399141be9db01092b15566c61e5e6 (diff) | |
download | rneovim-7475c1c0f795912ea5a4613a23c4ef5a1d88c24d.tar.gz rneovim-7475c1c0f795912ea5a4613a23c4ef5a1d88c24d.tar.bz2 rneovim-7475c1c0f795912ea5a4613a23c4ef5a1d88c24d.zip |
api: return error when starting a slice out of bounds.
Diffstat (limited to 'src/nvim/api/buffer.c')
-rw-r--r-- | src/nvim/api/buffer.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c index 9c29d41009..915c5f74d7 100644 --- a/src/nvim/api/buffer.c +++ b/src/nvim/api/buffer.c @@ -179,6 +179,11 @@ void buffer_set_line_slice(Buffer buffer, return; } + if (!inbounds(buf, start)) { + api_set_error(err, Validation, _("Index out of bounds")); + return; + } + start = normalize_index(buf, start) + (include_start ? 0 : 1); include_end = include_end || (end >= buf->b_ml.ml_line_count); end = normalize_index(buf, end) + (include_end ? 1 : 0); |