diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-02-16 19:05:11 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-02-16 19:05:11 +0100 |
commit | 55c77cf2ea9c15e1ec75d1faf702ec3c9e325271 (patch) | |
tree | 49838b82e5a5c75c477a716c692b8ce462b0b357 /src | |
parent | 8bfd9469cef536f171e6666f9d9217192e09d161 (diff) |
patch 8.1.0936: may leak memory when using 'vartabstop'v8.1.0936
Problem: May leak memory when using 'vartabstop'. (Kuang-che Wu)
Solution: Fix handling allocated memory for 'vartabstop'. (closes #3976)
Diffstat (limited to 'src')
-rw-r--r-- | src/buffer.c | 4 | ||||
-rw-r--r-- | src/option.c | 13 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 12 insertions, 7 deletions
diff --git a/src/buffer.c b/src/buffer.c index db0c591613..49d38ed31d 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -2170,9 +2170,7 @@ free_buf_options( vim_free(buf->b_p_vsts_array); buf->b_p_vsts_array = NULL; clear_string_option(&buf->b_p_vts); - if (buf->b_p_vts_array) - vim_free(buf->b_p_vts_array); - buf->b_p_vts_array = NULL; + VIM_CLEAR(buf->b_p_vts_array); #endif #ifdef FEAT_KEYMAP clear_string_option(&buf->b_p_keymap); diff --git a/src/option.c b/src/option.c index b9fe3dabef..eec8fe0520 100644 --- a/src/option.c +++ b/src/option.c @@ -5594,7 +5594,9 @@ didset_options2(void) (void)check_clipboard_option(); #endif #ifdef FEAT_VARTABS + vim_free(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); #endif } @@ -7572,14 +7574,14 @@ did_set_string_option( if (errmsg == NULL) { int *oldarray = 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 if (foldmethodIsIndent(curwin)) foldUpdateAll(curwin); -#endif /* FEAT_FOLDING */ +#endif } else errmsg = e_invarg; @@ -12706,10 +12708,11 @@ check_ff_value(char_u *p) 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'. + * "array" will be set, caller must free it if needed. */ int 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))); + if (*array == NULL) + return FALSE; (*array)[0] = valcount; t = 1; diff --git a/src/version.c b/src/version.c index 8dd86f0b00..81bafe5781 100644 --- a/src/version.c +++ b/src/version.c @@ -780,6 +780,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 936, +/**/ 935, /**/ 934, |