Patch 8.2.4453
Problem: :helpgrep may free an option that was not allocated. (Yegappan
Lakshmanan)
Solution: Check if the value was allocated.
Files: src/option.c, src/proto/option.pro, src/quickfix.c,
src/testdir/test_quickfix.vim
*** ../vim-8.2.4452/src/option.c 2022-02-12 11:51:20.048953988 +0000
--- src/option.c 2022-02-23 11:44:40.660119296 +0000
***************
*** 4479,4484 ****
--- 4479,4492 ----
return (char_u *)NULL;
}
+ int
+ is_option_allocated(char *name)
+ {
+ int idx = findoption((char_u *)name);
+
+ return idx >= 0 && (options[idx].flags & P_ALLOCED);
+ }
+
/*
* Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number.
* When "has_lt" is true there is a '<' before "*arg_arg".
*** ../vim-8.2.4452/src/proto/option.pro 2022-01-22 15:09:32.497898745
+0000
--- src/proto/option.pro 2022-02-23 11:46:13.776075740 +0000
***************
*** 41,46 ****
--- 41,47 ----
char_u *get_term_code(char_u *tname);
char_u *get_highlight_default(void);
char_u *get_encoding_default(void);
+ int is_option_allocated(char *name);
int makeset(FILE *fd, int opt_flags, int local_only);
int makefoldset(FILE *fd);
void clear_termoptions(void);
*** ../vim-8.2.4452/src/quickfix.c 2022-02-16 19:24:03.626162408 +0000
--- src/quickfix.c 2022-02-23 11:47:40.064022905 +0000
***************
*** 8235,8240 ****
--- 8235,8241 ----
{
regmatch_T regmatch;
char_u *save_cpo;
+ int save_cpo_allocated;
qf_info_T *qi = &ql_info;
int new_qi = FALSE;
char_u *au_name = NULL;
***************
*** 8265,8270 ****
--- 8266,8272 ----
// Make 'cpoptions' empty, the 'l' flag should not be used here.
save_cpo = p_cpo;
+ save_cpo_allocated = is_option_allocated("cpo");
p_cpo = empty_option;
incr_quickfix_busy();
***************
*** 8302,8308 ****
// changed and restored, need to restore in the complicated way.
if (*p_cpo == NUL)
set_option_value((char_u *)"cpo", 0L, save_cpo, 0);
! free_string_option(save_cpo);
}
if (updated)
--- 8304,8311 ----
// changed and restored, need to restore in the complicated way.
if (*p_cpo == NUL)
set_option_value((char_u *)"cpo", 0L, save_cpo, 0);
! if (save_cpo_allocated)
! free_string_option(save_cpo);
}
if (updated)
*** ../vim-8.2.4452/src/testdir/test_quickfix.vim 2022-02-08
18:08:49.940360054 +0000
--- src/testdir/test_quickfix.vim 2022-02-23 12:03:26.827024482 +0000
***************
*** 745,750 ****
--- 745,777 ----
helpclose
enddef
+ func Test_helpgrep_restore_cpo_aucmd()
+ let save_cpo = &cpo
+ augroup QF_Test
+ au!
+ autocmd BufNew * set cpo=acd
+ augroup END
+
+ helpgrep quickfix
+ call assert_equal('acd', &cpo)
+ %bw!
+
+ set cpo&vim
+ augroup QF_Test
+ au!
+ autocmd BufReadPost * set cpo=
+ augroup END
+
+ helpgrep buffer
+ call assert_equal('', &cpo)
+
+ augroup QF_Test
+ au!
+ augroup END
+ %bw!
+ let &cpo = save_cpo
+ endfunc
+
def Test_vim9_cexpr()
var text = 'somefile:95:error'
cexpr text
*** ../vim-8.2.4452/src/version.c 2022-02-23 10:52:39.058121947 +0000
--- src/version.c 2022-02-23 11:45:56.912084738 +0000
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 4453,
/**/
--
>From "know your smileys":
:-& Eating spaghetti
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20220223120730.5EEBD1C16F6%40moolenaar.net.