Patch 8.2.3513
Problem: Using freed memory when using a timer and searching. (Dominique
Pellé)
Solution: Allocated mr_pattern.
Files: src/search.c
*** ../vim-8.2.3512/src/search.c 2021-08-05 14:24:55.735550491 +0100
--- src/search.c 2021-10-15 12:40:33.005792554 +0100
***************
*** 84,98 ****
// copy of spats[], for keeping the search patterns while executing autocmds
static spat_T saved_spats[2];
# ifdef FEAT_SEARCH_EXTRA
static int saved_spats_last_idx = 0;
static int saved_spats_no_hlsearch = 0;
# endif
! static char_u *mr_pattern = NULL; // pattern used by search_regcomp()
! #ifdef FEAT_RIGHTLEFT
! static int mr_pattern_alloced = FALSE; // mr_pattern was allocated
! #endif
#ifdef FEAT_FIND_ID
/*
--- 84,97 ----
// copy of spats[], for keeping the search patterns while executing autocmds
static spat_T saved_spats[2];
+ static char_u *saved_mr_pattern = NULL;
# ifdef FEAT_SEARCH_EXTRA
static int saved_spats_last_idx = 0;
static int saved_spats_no_hlsearch = 0;
# endif
! // allocated copy of pattern used by search_regcomp()
! static char_u *mr_pattern = NULL;
#ifdef FEAT_FIND_ID
/*
***************
*** 161,189 ****
else if (options & SEARCH_HIS) // put new pattern in history
add_to_history(HIST_SEARCH, pat, TRUE, NUL);
#ifdef FEAT_RIGHTLEFT
- if (mr_pattern_alloced)
- {
- vim_free(mr_pattern);
- mr_pattern_alloced = FALSE;
- }
-
if (curwin->w_p_rl && *curwin->w_p_rlc == 's')
! {
! char_u *rev_pattern;
!
! rev_pattern = reverse_text(pat);
! if (rev_pattern == NULL)
! mr_pattern = pat; // out of memory, keep normal pattern.
! else
! {
! mr_pattern = rev_pattern;
! mr_pattern_alloced = TRUE;
! }
! }
else
#endif
! mr_pattern = pat;
/*
* Save the currently used pattern in the appropriate place,
--- 160,172 ----
else if (options & SEARCH_HIS) // put new pattern in history
add_to_history(HIST_SEARCH, pat, TRUE, NUL);
+ vim_free(mr_pattern);
#ifdef FEAT_RIGHTLEFT
if (curwin->w_p_rl && *curwin->w_p_rlc == 's')
! mr_pattern = reverse_text(pat);
else
#endif
! mr_pattern = vim_strsave(pat);
/*
* Save the currently used pattern in the appropriate place,
***************
*** 294,299 ****
--- 277,286 ----
saved_spats[1] = spats[1];
if (spats[1].pat != NULL)
saved_spats[1].pat = vim_strsave(spats[1].pat);
+ if (mr_pattern == NULL)
+ saved_mr_pattern = NULL;
+ else
+ saved_mr_pattern = vim_strsave(mr_pattern);
#ifdef FEAT_SEARCH_EXTRA
saved_spats_last_idx = last_idx;
saved_spats_no_hlsearch = no_hlsearch;
***************
*** 313,318 ****
--- 300,307 ----
#endif
vim_free(spats[1].pat);
spats[1] = saved_spats[1];
+ vim_free(mr_pattern);
+ mr_pattern = saved_mr_pattern;
#ifdef FEAT_SEARCH_EXTRA
last_idx = saved_spats_last_idx;
set_no_hlsearch(saved_spats_no_hlsearch);
***************
*** 326,340 ****
{
vim_free(spats[0].pat);
vim_free(spats[1].pat);
!
! # ifdef FEAT_RIGHTLEFT
! if (mr_pattern_alloced)
! {
! vim_free(mr_pattern);
! mr_pattern_alloced = FALSE;
! mr_pattern = NULL;
! }
! # endif
}
#endif
--- 315,321 ----
{
vim_free(spats[0].pat);
vim_free(spats[1].pat);
! VIM_CLEAR(mr_pattern);
}
#endif
*** ../vim-8.2.3512/src/version.c 2021-10-15 00:37:56.677890792 +0100
--- src/version.c 2021-10-15 12:41:45.774754777 +0100
***************
*** 759,760 ****
--- 759,762 ----
{ /* Add new patch number below this line */
+ /**/
+ 3513,
/**/
--
hundred-and-one symptoms of being an internet addict:
159. You get excited whenever discussing your hard drive.
/// Bram Moolenaar -- Br...@Moolenaar.net --
http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///