aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ops.c
diff options
context:
space:
mode:
authorIhor Antonov <ngortheone@users.noreply.github.com>2019-07-16 13:50:01 -0400
committerJustin M. Keyes <justinkz@gmail.com>2019-07-16 19:50:01 +0200
commitb9a2b3f01424e6f10a6134675e8fe7f96734bccf (patch)
tree55f50231651ac64f45ffc9a95d24488340a47492 /src/nvim/ops.c
parent583c35714ca8b541e9ddb8ec325b58f47cfe7bd5 (diff)
downloadrneovim-b9a2b3f01424e6f10a6134675e8fe7f96734bccf.tar.gz
rneovim-b9a2b3f01424e6f10a6134675e8fe7f96734bccf.tar.bz2
rneovim-b9a2b3f01424e6f10a6134675e8fe7f96734bccf.zip
PVS/V1028: cast operands, not the result #10503
Diffstat (limited to 'src/nvim/ops.c')
-rw-r--r--src/nvim/ops.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index fa58f7ba12..5fbcd54a19 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -1761,6 +1761,8 @@ int op_replace(oparg_T *oap, int c)
// insert replacement chars CHECK FOR ALLOCATED SPACE
// REPLACE_CR_NCHAR/REPLACE_NL_NCHAR is used for entering CR literally.
size_t after_p_len = 0;
+ int col = oldlen - bd.textcol - bd.textlen + 1;
+ assert(col >= 0);
if (had_ctrl_v_cr || (c != '\r' && c != '\n')) {
// strlen(newp) at this point
int newp_len = bd.textcol + bd.startspaces;
@@ -1772,12 +1774,11 @@ int op_replace(oparg_T *oap, int c)
memset(newp + newp_len, ' ', (size_t)bd.endspaces);
newp_len += bd.endspaces;
// copy the part after the changed part
- memmove(newp + newp_len, oldp,
- (size_t)(oldlen - bd.textcol - bd.textlen + 1));
+ memmove(newp + newp_len, oldp, (size_t)col);
}
} else {
// Replacing with \r or \n means splitting the line.
- after_p_len = (size_t)(oldlen - bd.textcol - bd.textlen + 1);
+ after_p_len = (size_t)col;
after_p = (char_u *)xmalloc(after_p_len);
memmove(after_p, oldp, after_p_len);
}