]> granicus.if.org Git - vim/commitdiff
patch 8.2.3492: crash when pasting too many times v8.2.3492
authorBram Moolenaar <Bram@vim.org>
Sun, 10 Oct 2021 11:35:17 +0000 (12:35 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 10 Oct 2021 11:35:17 +0000 (12:35 +0100)
Problem:    Crash when pasting too many times.
Solution:   Limit the size to what fits in an int. (closes #8962)

src/errors.h
src/register.c
src/testdir/test_put.vim
src/version.c

index a8ea33d1701d1a976613379883a5f809028fa2ab..4cc50e42c126375b7aef7e73ef9499b90bdfb588 100644 (file)
@@ -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"));
index f034c645b02ce9eb915e9a12ab2180a04e689b55..9f179ea1518c4ccb6cb99b5f2d3aaab3b62593af 100644 (file)
@@ -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)
index f3a320f463f5fe295ff85f2b6af0c0987556833f..4a3a0d19742b9418fa7b0b7914996eeadffb3446 100644 (file)
@@ -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
index 5fe4dcca6d57fe7d0440acb8a7d7478a38be484f..247af254cb3fa33ec9b35f9c4f92aa709b9be76f 100644 (file)
@@ -757,6 +757,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3492,
 /**/
     3491,
 /**/