aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIhor Antonov <ngortheone@users.noreply.github.com>2019-07-15 20:56:50 -0400
committerIhor Antonov <ngortheone@users.noreply.github.com>2019-07-16 08:28:50 -0400
commit6262d82d2fb70094fc8e6876d05a6efba798d3bf (patch)
tree419244e93648a68033e819fc030b8b971938d3ae /src
parentb06f29318df5adab76bba32b89b9af22043a39cb (diff)
downloadrneovim-6262d82d2fb70094fc8e6876d05a6efba798d3bf.tar.gz
rneovim-6262d82d2fb70094fc8e6876d05a6efba798d3bf.tar.bz2
rneovim-6262d82d2fb70094fc8e6876d05a6efba798d3bf.zip
pvs/V1028: cast operands, not the result
Diffstat (limited to 'src')
-rw-r--r--src/nvim/misc1.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c
index 6738e59bb2..cb6643f6cc 100644
--- a/src/nvim/misc1.c
+++ b/src/nvim/misc1.c
@@ -495,9 +495,14 @@ open_line (
}
if (lead_len > 0) {
// allocate buffer (may concatenate p_extra later)
- leader = xmalloc((size_t)(lead_len + lead_repl_len + extra_space
- + extra_len + (second_line_indent > 0
- ? second_line_indent : 0) + 1));
+ int bytes = lead_len
+ + lead_repl_len
+ + extra_space
+ + extra_len
+ + (second_line_indent > 0 ? second_line_indent : 0)
+ + 1;
+ assert( bytes >= 0 );
+ leader = xmalloc((size_t)bytes);
allocated = leader; // remember to free it later
STRLCPY(leader, saved_line, lead_len + 1);
@@ -1556,11 +1561,13 @@ void ins_str(char_u *s)
oldp = ml_get(lnum);
oldlen = (int)STRLEN(oldp);
- newp = (char_u *) xmalloc((size_t)(oldlen + newlen + 1));
+ newp = (char_u *) xmalloc((size_t)oldlen + (size_t)newlen + 1);
if (col > 0)
memmove(newp, oldp, (size_t)col);
memmove(newp + col, s, (size_t)newlen);
- memmove(newp + col + newlen, oldp + col, (size_t)(oldlen - col + 1));
+ int bytes = oldlen - col + 1;
+ assert(bytes >= 0);
+ memmove(newp + col + newlen, oldp + col, bytes);
ml_replace(lnum, newp, false);
changed_bytes(lnum, col);
curwin->w_cursor.col += newlen;