fix(options): properly free string options (#19510)

This commit is contained in:
zeertzjq
2022-07-27 07:26:32 +08:00
committed by GitHub
parent 890d4023cd
commit 79872f3770
4 changed files with 18 additions and 8 deletions

View File

@@ -1423,7 +1423,7 @@ void diff_win_options(win_T *wp, int addbuf)
}
wp->w_p_fdc_save = vim_strsave(wp->w_p_fdc);
}
xfree(wp->w_p_fdc);
free_string_option(wp->w_p_fdc);
wp->w_p_fdc = (char_u *)xstrdup("2");
assert(diff_foldcolumn >= 0 && diff_foldcolumn <= 9);
snprintf((char *)wp->w_p_fdc, STRLEN(wp->w_p_fdc) + 1, "%d", diff_foldcolumn);

View File

@@ -451,7 +451,7 @@ void terminal_enter(void)
if (save_curwin == curwin->handle) { // Else: window was closed.
curwin->w_p_cul = save_w_p_cul;
if (save_w_p_culopt) {
xfree(curwin->w_p_culopt);
free_string_option(curwin->w_p_culopt);
curwin->w_p_culopt = save_w_p_culopt;
}
curwin->w_p_culopt_flags = save_w_p_culopt_flags;
@@ -459,7 +459,7 @@ void terminal_enter(void)
curwin->w_p_so = save_w_p_so;
curwin->w_p_siso = save_w_p_siso;
} else if (save_w_p_culopt) {
xfree(save_w_p_culopt);
free_string_option(save_w_p_culopt);
}
// draw the unfocused cursor

View File

@@ -726,31 +726,31 @@ void win_set_minimal_style(win_T *wp)
wp->w_p_fcs = ((*old == NUL)
? (char_u *)xstrdup("eob: ")
: concat_str(old, (char_u *)",eob: "));
xfree(old);
free_string_option(old);
}
if (wp->w_hl_ids[HLF_EOB] != -1) {
char_u *old = wp->w_p_winhl;
wp->w_p_winhl = ((*old == NUL)
? (char_u *)xstrdup("EndOfBuffer:")
: concat_str(old, (char_u *)",EndOfBuffer:"));
xfree(old);
free_string_option(old);
}
// signcolumn: use 'auto'
if (wp->w_p_scl[0] != 'a' || STRLEN(wp->w_p_scl) >= 8) {
xfree(wp->w_p_scl);
free_string_option(wp->w_p_scl);
wp->w_p_scl = (char_u *)xstrdup("auto");
}
// foldcolumn: use '0'
if (wp->w_p_fdc[0] != '0') {
xfree(wp->w_p_fdc);
free_string_option(wp->w_p_fdc);
wp->w_p_fdc = (char_u *)xstrdup("0");
}
// colorcolumn: cleared
if (wp->w_p_cc != NULL && *wp->w_p_cc != NUL) {
xfree(wp->w_p_cc);
free_string_option(wp->w_p_cc);
wp->w_p_cc = (char_u *)xstrdup("");
}
}