From 566048240625c5ac9404dfa4c490dbe40105824d Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 2 Apr 2018 00:41:00 +0300 Subject: api/buffer: Fix PVS/V547: use correct border for lnum Should actually be silencing that for the sake of the case when `long` is actually not 64-bit. But it appears that Vim had already defined maximal line number. And even declared that exact value invalid, so no need in silencing. --- src/nvim/api/buffer.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/nvim/api') 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; } -- cgit From d9c010e45d5078b98bebb031a3583489c9e8bd32 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 22 Apr 2018 20:23:50 +0300 Subject: api/vim: Fix PVS/V547: node was already dereferenced, so can’t be NULL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/nvim/api/vim.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/api') diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 962081cc23..86827224b7 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -1198,7 +1198,7 @@ Dictionary nvim_parse_expression(String expr, String flags, Boolean highlight, .node_p = &node->next, .ret_node_p = cur_item.ret_node_p + 1, })); - } else if (node != NULL) { + } else { kv_drop(ast_conv_stack, 1); ret_node->items[ret_node->size++] = (KeyValuePair) { .key = STATIC_CSTR_TO_STRING("type"), -- cgit