summaryrefslogtreecommitdiffstats
path: root/src/channel.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-01-30 16:27:20 +0100
committerBram Moolenaar <Bram@vim.org>2020-01-30 16:27:20 +0100
commit21109272f5b0d32c408dc292561c0b1f2f8ebc53 (patch)
tree40959604cbf5e45989ba592ceb28c1fc11a9784c /src/channel.c
parent0c3064b39b4cd4f22fe1eab5438fe691d7cc80d1 (diff)
patch 8.2.0181: problems parsing :term argumentsv8.2.0181
Problem: Problems parsing :term arguments. Solution: Improve parsing, fix memory leak, add tests. (Ozaki Kiichi, closes #5536)
Diffstat (limited to 'src/channel.c')
-rw-r--r--src/channel.c43
1 files changed, 29 insertions, 14 deletions
diff --git a/src/channel.c b/src/channel.c
index 3fdd312b38..d5240fc25e 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -4787,8 +4787,8 @@ get_job_options(typval_T *tv, jobopt_T *opt, int supported, int supported2)
if (!(supported & JO_OUT_IO))
break;
opt->jo_set |= JO_OUT_NAME << (part - PART_OUT);
- opt->jo_io_name[part] =
- tv_get_string_buf_chk(item, opt->jo_io_name_buf[part]);
+ opt->jo_io_name[part] = tv_get_string_buf_chk(item,
+ opt->jo_io_name_buf[part]);
}
else if (STRCMP(hi->hi_key, "pty") == 0)
{
@@ -4953,7 +4953,8 @@ get_job_options(typval_T *tv, jobopt_T *opt, int supported, int supported2)
if (!(supported2 & JO2_TERM_NAME))
break;
opt->jo_set2 |= JO2_TERM_NAME;
- opt->jo_term_name = tv_get_string_chk(item);
+ opt->jo_term_name = tv_get_string_buf_chk(item,
+ opt->jo_term_name_buf);
if (opt->jo_term_name == NULL)
{
semsg(_(e_invargval), "term_name");
@@ -4980,7 +4981,8 @@ get_job_options(typval_T *tv, jobopt_T *opt, int supported, int supported2)
if (!(supported2 & JO2_TERM_OPENCMD))
break;
opt->jo_set2 |= JO2_TERM_OPENCMD;
- p = opt->jo_term_opencmd = tv_get_string_chk(item);
+ p = opt->jo_term_opencmd = tv_get_string_buf_chk(item,
+ opt->jo_term_opencmd_buf);
if (p != NULL)
{
// Must have %d and no other %.
@@ -4997,13 +4999,12 @@ get_job_options(typval_T *tv, jobopt_T *opt, int supported, int supported2)
}
else if (STRCMP(hi->hi_key, "eof_chars") == 0)
{
- char_u *p;
-
if (!(supported2 & JO2_EOF_CHARS))
break;
opt->jo_set2 |= JO2_EOF_CHARS;
- p = opt->jo_eof_chars = tv_get_string_chk(item);
- if (p == NULL)
+ opt->jo_eof_chars = tv_get_string_buf_chk(item,
+ opt->jo_eof_chars_buf);
+ if (opt->jo_eof_chars == NULL)
{
semsg(_(e_invargval), "eof_chars");
return FAIL;
@@ -5082,7 +5083,13 @@ get_job_options(typval_T *tv, jobopt_T *opt, int supported, int supported2)
if (!(supported2 & JO2_TERM_KILL))
break;
opt->jo_set2 |= JO2_TERM_KILL;
- opt->jo_term_kill = tv_get_string_chk(item);
+ opt->jo_term_kill = tv_get_string_buf_chk(item,
+ opt->jo_term_kill_buf);
+ if (opt->jo_term_kill == NULL)
+ {
+ semsg(_(e_invargval), "term_kill");
+ return FAIL;
+ }
}
else if (STRCMP(hi->hi_key, "tty_type") == 0)
{
@@ -5157,7 +5164,12 @@ get_job_options(typval_T *tv, jobopt_T *opt, int supported, int supported2)
break;
opt->jo_set2 |= JO2_TERM_API;
opt->jo_term_api = tv_get_string_buf_chk(item,
- opt->jo_term_api_buf);
+ opt->jo_term_api_buf);
+ if (opt->jo_term_api == NULL)
+ {
+ semsg(_(e_invargval), "term_api");
+ return FAIL;
+ }
}
#endif
else if (STRCMP(hi->hi_key, "env") == 0)
@@ -5247,7 +5259,7 @@ get_job_options(typval_T *tv, jobopt_T *opt, int supported, int supported2)
break;
opt->jo_set |= JO_STOPONEXIT;
opt->jo_stoponexit = tv_get_string_buf_chk(item,
- opt->jo_soe_buf);
+ opt->jo_stoponexit_buf);
if (opt->jo_stoponexit == NULL)
{
semsg(_(e_invargval), "stoponexit");
@@ -5817,7 +5829,7 @@ job_start(
typval_T *argvars,
char **argv_arg UNUSED,
jobopt_T *opt_arg,
- int is_terminal UNUSED)
+ job_T **term_job)
{
job_T *job;
char_u *cmd = NULL;
@@ -5968,6 +5980,9 @@ job_start(
// Save the command used to start the job.
job->jv_argv = argv;
+ if (term_job != NULL)
+ *term_job = job;
+
#ifdef USE_ARGV
if (ch_log_active())
{
@@ -5984,7 +5999,7 @@ job_start(
ch_log(NULL, "Starting job: %s", (char *)ga.ga_data);
ga_clear(&ga);
}
- mch_job_start(argv, job, &opt, is_terminal);
+ mch_job_start(argv, job, &opt, term_job != NULL);
#else
ch_log(NULL, "Starting job: %s", (char *)cmd);
mch_job_start((char *)cmd, job, &opt);
@@ -6600,7 +6615,7 @@ f_job_start(typval_T *argvars, typval_T *rettv)
rettv->v_type = VAR_JOB;
if (check_restricted() || check_secure())
return;
- rettv->vval.v_job = job_start(argvars, NULL, NULL, FALSE);
+ rettv->vval.v_job = job_start(argvars, NULL, NULL, NULL);
}
/*