summaryrefslogtreecommitdiffstats
path: root/src/mbyte.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2021-10-20 11:01:15 +0100
committerBram Moolenaar <Bram@vim.org>2021-10-20 11:01:15 +0100
commit94358a1e6e640ca5ebeb295efdddd4e92b700673 (patch)
tree81179f39149f91396d2c5af7c70ed758c326fbce /src/mbyte.c
parent051a40c8d91d4595c69a27375f739367d806a475 (diff)
patch 8.2.3545: setcellwidths() may make 'listchars' or 'fillchars' invalidv8.2.3545
Problem: setcellwidths() may make 'listchars' or 'fillchars' invalid. Solution: Check the value and give an error. (closes #9024)
Diffstat (limited to 'src/mbyte.c')
-rw-r--r--src/mbyte.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/src/mbyte.c b/src/mbyte.c
index a626f50c60..76eab4e2ec 100644
--- a/src/mbyte.c
+++ b/src/mbyte.c
@@ -5510,6 +5510,8 @@ f_setcellwidths(typval_T *argvars, typval_T *rettv UNUSED)
int i;
listitem_T **ptrs;
cw_interval_T *table;
+ cw_interval_T *cw_table_save;
+ size_t cw_table_size_save;
if (in_vim9script() && check_for_list_arg(argvars, 0) == FAIL)
return;
@@ -5620,9 +5622,41 @@ f_setcellwidths(typval_T *argvars, typval_T *rettv UNUSED)
}
vim_free(ptrs);
- vim_free(cw_table);
+
+ cw_table_save = cw_table;
+ cw_table_size_save = cw_table_size;
cw_table = table;
cw_table_size = l->lv_len;
+
+ // Check that the new value does not conflict with 'fillchars' or
+ // 'listchars'.
+ if (set_chars_option(curwin, &p_fcs) != NULL)
+ {
+ emsg(_(e_conflicts_with_value_of_fillchars));
+ cw_table = cw_table_save;
+ cw_table_size = cw_table_size_save;
+ vim_free(table);
+ return;
+ }
+ else
+ {
+ tabpage_T *tp;
+ win_T *wp;
+
+ FOR_ALL_TAB_WINDOWS(tp, wp)
+ {
+ if (set_chars_option(wp, &wp->w_p_lcs) != NULL)
+ {
+ emsg((e_conflicts_with_value_of_listchars));
+ cw_table = cw_table_save;
+ cw_table_size = cw_table_size_save;
+ vim_free(table);
+ return;
+ }
+ }
+ }
+
+ vim_free(cw_table_save);
}
void