changeset 26113:c421c9599d83 v8.2.3589

patch 8.2.3589: failure when "term_rows" of term_start() is an unusual value Commit: https://github.com/vim/vim/commit/5300be620c77950caa5296019408ee02e60097e8 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Nov 13 10:27:40 2021 +0000 patch 8.2.3589: failure when "term_rows" of term_start() is an unusual value Problem: Failure when the "term_rows" argument of term_start() is an unusual value. Solution: Limit to range of zero to 1000. (closes #9116)
author Bram Moolenaar <Bram@vim.org>
date Sat, 13 Nov 2021 11:30:05 +0100
parents 46874de42a18
children 32f4ca8378c3
files runtime/doc/terminal.txt src/job.c src/testdir/test_terminal.vim src/version.c
diffstat 4 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/runtime/doc/terminal.txt
+++ b/runtime/doc/terminal.txt
@@ -871,7 +871,8 @@ term_start({cmd} [, {options}])			*term_
 		   "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
--- a/src/job.c
+++ b/src/job.c
@@ -432,6 +432,11 @@ get_job_options(typval_T *tv, jobopt_T *
 		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)
 	    {
--- a/src/testdir/test_terminal.vim
+++ b/src/testdir/test_terminal.vim
@@ -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
--- 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 */
 /**/
+    3589,
+/**/
     3588,
 /**/
     3587,