diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-10-10 12:35:17 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-10-10 12:35:17 +0100 |
commit | eeed1c7ae090c17f4df51cf97b2a9e4d8b4f4dc7 (patch) | |
tree | 15c5bc0f2c667d4afaec3a2ae224165e11d059b1 | |
parent | 6e77b88df6371356cce9d6e08daf0f7cb1e7878a (diff) | |
download | vim-git-eeed1c7ae090c17f4df51cf97b2a9e4d8b4f4dc7.tar.gz |
patch 8.2.3492: crash when pasting too many timesv8.2.3492
Problem: Crash when pasting too many times.
Solution: Limit the size to what fits in an int. (closes #8962)
-rw-r--r-- | src/errors.h | 2 | ||||
-rw-r--r-- | src/register.c | 11 | ||||
-rw-r--r-- | src/testdir/test_put.vim | 8 | ||||
-rw-r--r-- | src/version.c | 2 |
4 files changed, 21 insertions, 2 deletions
diff --git a/src/errors.h b/src/errors.h index a8ea33d17..4cc50e42c 100644 --- a/src/errors.h +++ b/src/errors.h @@ -664,3 +664,5 @@ EXTERN char e_blob_required_for_argument_nr[] INIT(= N_("E1238: Blob required for argument %d")); EXTERN char e_invalid_value_for_blob_nr[] INIT(= N_("E1239: Invalid value for blob: %d")); +EXTERN char e_resulting_text_too_long[] + INIT(= N_("E1240: Resulting text too long")); diff --git a/src/register.c b/src/register.c index f034c645b..9f179ea15 100644 --- a/src/register.c +++ b/src/register.c @@ -2011,8 +2011,15 @@ do_put( } do { - totlen = count * yanklen; - if (totlen > 0) + long multlen = count * yanklen; + + totlen = multlen; + if (totlen != multlen) + { + emsg(_(e_resulting_text_too_long)); + break; + } + else if (totlen > 0) { oldp = ml_get(lnum); if (lnum > start_lnum) diff --git a/src/testdir/test_put.vim b/src/testdir/test_put.vim index f3a320f46..4a3a0d197 100644 --- a/src/testdir/test_put.vim +++ b/src/testdir/test_put.vim @@ -134,4 +134,12 @@ func Test_gp_with_count_leaves_cursor_at_end() bwipe! endfunc +func Test_very_larg_count() + new + let @" = 'x' + call assert_fails('norm 44444444444444p', 'E1240:') + bwipe! +endfunc + + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/version.c b/src/version.c index 5fe4dcca6..247af254c 100644 --- a/src/version.c +++ b/src/version.c @@ -758,6 +758,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 3492, +/**/ 3491, /**/ 3490, |