aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/option.c
diff options
context:
space:
mode:
authorDevon Gardner <devon@goosur.com>2025-01-18 19:49:53 -0500
committerGitHub <noreply@github.com>2025-01-19 08:49:53 +0800
commit71507281fb86deaaa7f47460e8c7a503b46663f6 (patch)
tree688a8cfdc31852b09af3323cf20ad8197c8af79f /src/nvim/option.c
parenta5b1b83a2693ffa7a5a0a22b3693d36ea60051be (diff)
downloadrneovim-71507281fb86deaaa7f47460e8c7a503b46663f6.tar.gz
rneovim-71507281fb86deaaa7f47460e8c7a503b46663f6.tar.bz2
rneovim-71507281fb86deaaa7f47460e8c7a503b46663f6.zip
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)
Diffstat (limited to 'src/nvim/option.c')
-rw-r--r--src/nvim/option.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/nvim/option.c b/src/nvim/option.c
index 073a816d0c..f9eb67ff83 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -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
// 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;
}
// 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;
}
@@ -3267,7 +3267,7 @@ bool is_option_hidden(OptIndex opt_idx)
/// Check if option supports a specific 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.