0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 8.2.4453: :helpgrep may free an option that was not allocated

Problem:    :helpgrep may free an option that was not allocated. (Yegappan
            Lakshmanan)
Solution:   Check if the value was allocated.
This commit is contained in:
Bram Moolenaar
2022-02-23 12:06:00 +00:00
parent 2dada73a4e
commit 4791fcd825
5 changed files with 42 additions and 1 deletions

View File

@@ -8235,6 +8235,7 @@ ex_helpgrep(exarg_T *eap)
{
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,6 +8266,7 @@ ex_helpgrep(exarg_T *eap)
// 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,7 +8304,8 @@ ex_helpgrep(exarg_T *eap)
// 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 (save_cpo_allocated)
free_string_option(save_cpo);
}
if (updated)