diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2018-04-27 09:25:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-27 09:25:02 +0200 |
commit | 53f11dcfc7139fe6c8a6b114db4bfec5d91005a9 (patch) | |
tree | e9bfbaf10fc6681bbbcba0a0eabdce8a6f6840b5 /src/nvim/api/buffer.c | |
parent | 009ccfe170ada2c78ca7feabda567a7e901fb30b (diff) | |
parent | 4ce8521ee4a72e050bd187c2986708c5f98c7442 (diff) | |
download | rneovim-53f11dcfc7139fe6c8a6b114db4bfec5d91005a9.tar.gz rneovim-53f11dcfc7139fe6c8a6b114db4bfec5d91005a9.tar.bz2 rneovim-53f11dcfc7139fe6c8a6b114db4bfec5d91005a9.zip |
Merge #8218 'Fix errors reported by PVS'
closes #4983
Diffstat (limited to 'src/nvim/api/buffer.c')
-rw-r--r-- | src/nvim/api/buffer.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c index af723639c5..6be981a18e 100644 --- a/src/nvim/api/buffer.c +++ b/src/nvim/api/buffer.c @@ -186,12 +186,12 @@ ArrayOf(String) nvim_buf_get_lines(uint64_t channel_id, for (size_t i = 0; i < rv.size; i++) { int64_t lnum = start + (int64_t)i; - if (lnum > LONG_MAX) { + if (lnum >= MAXLNUM) { api_set_error(err, kErrorTypeValidation, "Line index is too high"); goto end; } - const char *bufstr = (char *) ml_get_buf(buf, (linenr_T) lnum, false); + const char *bufstr = (char *)ml_get_buf(buf, (linenr_T)lnum, false); Object str = STRING_OBJ(cstr_to_string(bufstr)); // Vim represents NULs as NLs, but this may confuse clients. @@ -360,7 +360,7 @@ void nvim_buf_set_lines(uint64_t channel_id, for (size_t i = 0; i < to_replace; i++) { int64_t lnum = start + (int64_t)i; - if (lnum > LONG_MAX) { + if (lnum >= MAXLNUM) { api_set_error(err, kErrorTypeValidation, "Index value is too high"); goto end; } @@ -378,7 +378,7 @@ void nvim_buf_set_lines(uint64_t channel_id, for (size_t i = to_replace; i < new_len; i++) { int64_t lnum = start + (int64_t)i - 1; - if (lnum > LONG_MAX) { + if (lnum >= MAXLNUM) { api_set_error(err, kErrorTypeValidation, "Index value is too high"); goto end; } |