diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-08-08 12:08:28 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2022-08-08 20:03:40 +0800 |
commit | 9fedb6fd783b9ac48239bc7574779118eec3729a (patch) | |
tree | 7d8cb54de0dc1fc4ad9ddac1715cf3f34bdd329a /src/nvim/mbyte.c | |
parent | 01a7009af9f7bbf5f1b38c82956caf67a7c8bcca (diff) | |
download | rneovim-9fedb6fd783b9ac48239bc7574779118eec3729a.tar.gz rneovim-9fedb6fd783b9ac48239bc7574779118eec3729a.tar.bz2 rneovim-9fedb6fd783b9ac48239bc7574779118eec3729a.zip |
vim-patch:8.2.3545: setcellwidths() may make 'listchars' or 'fillchars' invalid
Problem: setcellwidths() may make 'listchars' or 'fillchars' invalid.
Solution: Check the value and give an error. (closes vim/vim#9024)
https://github.com/vim/vim/commit/94358a1e6e640ca5ebeb295efdddd4e92b700673
Cherry-pick f_setcellwidths() change from patch 9.0.0036.
Cherry-pick 'ambiwidth' docs update from runtime update 079ba76ae7a7.
Diffstat (limited to 'src/nvim/mbyte.c')
-rw-r--r-- | src/nvim/mbyte.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index e19c356343..5de7231a0a 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -2838,7 +2838,38 @@ void f_setcellwidths(typval_T *argvars, typval_T *rettv, FunPtr fptr) } xfree(ptrs); - xfree(cw_table); + + cw_interval_T *const cw_table_save = cw_table; + const size_t cw_table_size_save = cw_table_size; cw_table = table; cw_table_size = (size_t)tv_list_len(l); + + // Check that the new value does not conflict with 'fillchars' or + // 'listchars'. + char *error = NULL; + if (set_chars_option(curwin, &p_fcs, false) != NULL) { + error = e_conflicts_with_value_of_fillchars; + } else if (set_chars_option(curwin, &p_lcs, false) != NULL) { + error = e_conflicts_with_value_of_listchars; + } else { + FOR_ALL_TAB_WINDOWS(tp, wp) { + if (set_chars_option(wp, &wp->w_p_lcs, false) != NULL) { + error = e_conflicts_with_value_of_listchars; + break; + } + if (set_chars_option(wp, &wp->w_p_fcs, false) != NULL) { + error = e_conflicts_with_value_of_fillchars; + break; + } + } + } + if (error != NULL) { + emsg(_(error)); + cw_table = cw_table_save; + cw_table_size = cw_table_size_save; + xfree(table); + return; + } + + xfree(cw_table_save); } |