mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
fix(coverity/530826): validate_opt_idx unchecked negative idx (#32081)
Problem: opt_idx possible negative value used as index Solution: check opt_idx not less than zero (kOptInvalid)
This commit is contained in:
parent
a5b1b83a26
commit
71507281fb
@ -980,12 +980,12 @@ static int validate_opt_idx(win_T *win, OptIndex opt_idx, int opt_flags, uint32_
|
|||||||
|
|
||||||
// Skip all options that are not window-local (used when showing
|
// Skip all options that are not window-local (used when showing
|
||||||
// an already loaded buffer in a window).
|
// an already loaded buffer in a window).
|
||||||
if ((opt_flags & OPT_WINONLY) && (opt_idx == kOptInvalid || !option_is_window_local(opt_idx))) {
|
if ((opt_flags & OPT_WINONLY) && !option_is_window_local(opt_idx)) {
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip all options that are window-local (used for :vimgrep).
|
// Skip all options that are window-local (used for :vimgrep).
|
||||||
if ((opt_flags & OPT_NOWIN) && opt_idx != kOptInvalid && option_is_window_local(opt_idx)) {
|
if ((opt_flags & OPT_NOWIN) && option_is_window_local(opt_idx)) {
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3267,7 +3267,7 @@ bool is_option_hidden(OptIndex opt_idx)
|
|||||||
/// Check if option supports a specific type.
|
/// Check if option supports a specific type.
|
||||||
bool option_has_type(OptIndex opt_idx, OptValType type)
|
bool option_has_type(OptIndex opt_idx, OptValType type)
|
||||||
{
|
{
|
||||||
return options[opt_idx].type == type;
|
return opt_idx != kOptInvalid && options[opt_idx].type == type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if option supports a specific scope.
|
/// Check if option supports a specific scope.
|
||||||
|
Loading…
Reference in New Issue
Block a user