vim-patch:8.1.0936: may leak memory when using 'vartabstop'

Problem:    May leak memory when using 'vartabstop'. (Kuang-che Wu)
Solution:   Fix handling allocated memory for 'vartabstop'. (closes vim/vim#3976)
55c77cf2ea
This commit is contained in:
Jan Edmund Lazo 2021-03-30 19:51:38 -04:00
parent e491e77498
commit 608c03298a
No known key found for this signature in database
GPG Key ID: 64915E6E9F735B15

View File

@ -2001,7 +2001,9 @@ static void didset_options2(void)
// Parse default for 'wildmode'.
check_opt_wim();
xfree(curbuf->b_p_vsts_array);
tabstop_set(curbuf->b_p_vsts, &curbuf->b_p_vsts_array);
xfree(curbuf->b_p_vts_array);
tabstop_set(curbuf->b_p_vts, &curbuf->b_p_vts_array);
}
@ -3167,9 +3169,7 @@ ambw_end:
if (errmsg == NULL) {
long *oldarray = curbuf->b_p_vts_array;
if (tabstop_set(*varp, &(curbuf->b_p_vts_array))) {
if (oldarray) {
xfree(oldarray);
}
xfree(oldarray);
if (foldmethodIsIndent(curwin)) {
foldUpdateAll(curwin);
}