mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
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 #3976)
This commit is contained in:
@@ -2170,9 +2170,7 @@ free_buf_options(
|
|||||||
vim_free(buf->b_p_vsts_array);
|
vim_free(buf->b_p_vsts_array);
|
||||||
buf->b_p_vsts_array = NULL;
|
buf->b_p_vsts_array = NULL;
|
||||||
clear_string_option(&buf->b_p_vts);
|
clear_string_option(&buf->b_p_vts);
|
||||||
if (buf->b_p_vts_array)
|
VIM_CLEAR(buf->b_p_vts_array);
|
||||||
vim_free(buf->b_p_vts_array);
|
|
||||||
buf->b_p_vts_array = NULL;
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef FEAT_KEYMAP
|
#ifdef FEAT_KEYMAP
|
||||||
clear_string_option(&buf->b_p_keymap);
|
clear_string_option(&buf->b_p_keymap);
|
||||||
|
11
src/option.c
11
src/option.c
@@ -5594,7 +5594,9 @@ didset_options2(void)
|
|||||||
(void)check_clipboard_option();
|
(void)check_clipboard_option();
|
||||||
#endif
|
#endif
|
||||||
#ifdef FEAT_VARTABS
|
#ifdef FEAT_VARTABS
|
||||||
|
vim_free(curbuf->b_p_vsts_array);
|
||||||
tabstop_set(curbuf->b_p_vsts, &curbuf->b_p_vsts_array);
|
tabstop_set(curbuf->b_p_vsts, &curbuf->b_p_vsts_array);
|
||||||
|
vim_free(curbuf->b_p_vts_array);
|
||||||
tabstop_set(curbuf->b_p_vts, &curbuf->b_p_vts_array);
|
tabstop_set(curbuf->b_p_vts, &curbuf->b_p_vts_array);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -7572,14 +7574,14 @@ did_set_string_option(
|
|||||||
if (errmsg == NULL)
|
if (errmsg == NULL)
|
||||||
{
|
{
|
||||||
int *oldarray = curbuf->b_p_vts_array;
|
int *oldarray = curbuf->b_p_vts_array;
|
||||||
|
|
||||||
if (tabstop_set(*varp, &(curbuf->b_p_vts_array)))
|
if (tabstop_set(*varp, &(curbuf->b_p_vts_array)))
|
||||||
{
|
{
|
||||||
if (oldarray)
|
|
||||||
vim_free(oldarray);
|
vim_free(oldarray);
|
||||||
#ifdef FEAT_FOLDING
|
#ifdef FEAT_FOLDING
|
||||||
if (foldmethodIsIndent(curwin))
|
if (foldmethodIsIndent(curwin))
|
||||||
foldUpdateAll(curwin);
|
foldUpdateAll(curwin);
|
||||||
#endif /* FEAT_FOLDING */
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
errmsg = e_invarg;
|
errmsg = e_invarg;
|
||||||
@@ -12706,10 +12708,11 @@ check_ff_value(char_u *p)
|
|||||||
return check_opt_strings(p, p_ff_values, FALSE);
|
return check_opt_strings(p, p_ff_values, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef FEAT_VARTABS
|
#if defined(FEAT_VARTABS) || defined(PROTO)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set the integer values corresponding to the string setting of 'vartabstop'.
|
* Set the integer values corresponding to the string setting of 'vartabstop'.
|
||||||
|
* "array" will be set, caller must free it if needed.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
tabstop_set(char_u *var, int **array)
|
tabstop_set(char_u *var, int **array)
|
||||||
@@ -12752,6 +12755,8 @@ tabstop_set(char_u *var, int **array)
|
|||||||
}
|
}
|
||||||
|
|
||||||
*array = (int *)alloc((unsigned) ((valcount + 1) * sizeof(int)));
|
*array = (int *)alloc((unsigned) ((valcount + 1) * sizeof(int)));
|
||||||
|
if (*array == NULL)
|
||||||
|
return FALSE;
|
||||||
(*array)[0] = valcount;
|
(*array)[0] = valcount;
|
||||||
|
|
||||||
t = 1;
|
t = 1;
|
||||||
|
@@ -779,6 +779,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
936,
|
||||||
/**/
|
/**/
|
||||||
935,
|
935,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user