aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/ops.c9
-rw-r--r--src/nvim/testdir/test_put.vim7
2 files changed, 14 insertions, 2 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index 18facef13c..e6e617a419 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -3431,8 +3431,13 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
}
do {
- totlen = (size_t)(count * yanklen);
- if (totlen > 0) {
+ const long multlen = count * yanklen;
+
+ totlen = (size_t)(int)multlen;
+ if (totlen != (size_t)multlen) {
+ emsg(_(e_resulting_text_too_long));
+ break;
+ } else if (totlen > 0) {
oldp = ml_get(lnum);
if (lnum > start_lnum) {
pos_T pos = {
diff --git a/src/nvim/testdir/test_put.vim b/src/nvim/testdir/test_put.vim
index ed76709a56..cef2cf0dd7 100644
--- a/src/nvim/testdir/test_put.vim
+++ b/src/nvim/testdir/test_put.vim
@@ -138,6 +138,13 @@ func Test_p_with_count_leaves_mark_at_end()
bwipe!
endfunc
+func Test_very_larg_count()
+ new
+ let @" = 'x'
+ call assert_fails('norm 44444444444444p', 'E1240:')
+ bwipe!
+endfunc
+
func Test_put_above_first_line()
new
let @" = 'text'