]> granicus.if.org Git - vim/commitdiff
patch 8.2.3589: failure when "term_rows" of term_start() is an unusual value v8.2.3589
authorBram Moolenaar <Bram@vim.org>
Sat, 13 Nov 2021 10:27:40 +0000 (10:27 +0000)
committerBram Moolenaar <Bram@vim.org>
Sat, 13 Nov 2021 10:27:40 +0000 (10:27 +0000)
Problem:    Failure when the "term_rows" argument of term_start() is an
            unusual value.
Solution:   Limit to range of zero to 1000. (closes #9116)

runtime/doc/terminal.txt
src/job.c
src/testdir/test_terminal.vim
src/version.c

index 510f1c399b8376c4ac5d4a393880b9d8ba5d492d..47b04df2fc091c340b38eafb1fcc239b297ed28a 100644 (file)
@@ -871,7 +871,8 @@ term_start({cmd} [, {options}])                     *term_start()*
                   "term_name"       name to use for the buffer name, instead
                                     of the command name.
                   "term_rows"       vertical size to use for the terminal,
-                                    instead of using 'termwinsize'
+                                    instead of using 'termwinsize'; valid
+                                    range is from zero to 1000
                   "term_cols"       horizontal size to use for the terminal,
                                     instead of using 'termwinsize'
                   "vertical"        split the window vertically; note that
index 80cb47eeb179d4aada39987f7e57d7f725134f1f..a2e184b12c4731b55db07c74e245cffa2da014c6 100644 (file)
--- a/src/job.c
+++ b/src/job.c
@@ -432,6 +432,11 @@ get_job_options(typval_T *tv, jobopt_T *opt, int supported, int supported2)
                opt->jo_term_rows = tv_get_number_chk(item, &error);
                if (error)
                    return FAIL;
+               if (opt->jo_term_rows < 0 || opt->jo_term_rows > 1000)
+               {
+                   semsg(_(e_invargval), "term_rows");
+                   return FAIL;
+               }
            }
            else if (STRCMP(hi->hi_key, "term_cols") == 0)
            {
index 3e263efd2723c66aa7b0e6e4c885b9fb55fba488..cd7f477c262cd6de59e1e5271c7a4acd63ef3b91 100644 (file)
@@ -467,6 +467,8 @@ func Test_terminal_size()
   bwipe!
   call assert_equal([7, 27], size)
 
+  call assert_fails("call term_start(cmd, {'term_rows': -1})", 'E475:')
+  call assert_fails("call term_start(cmd, {'term_rows': 1001})", 'E475:')
   if has('float')
     call assert_fails("call term_start(cmd, {'term_rows': 10.0})", 'E805:')
   endif
index 4be3fd2f5d06548495e095d9a46577fce7c5cdf5..8e2a10b27ccb7260f9d5ae4cf012183138be22b3 100644 (file)
@@ -757,6 +757,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3589,
 /**/
     3588,
 /**/