From bff07f6dd0d8e58748f36670685dd6157a67976b Mon Sep 17 00:00:00 2001 From: Famiu Haque Date: Fri, 22 Nov 2024 18:32:51 +0600 Subject: fix(api): don't try to get/set option for invalid option name (#31302) Problem: `validate_option_value_args()` returns `OK` even if option name is invalid or if option doesn't have the supported scope, which leads to Neovim still trying to erroneously get/set the option in those cases, which can lead to an assertion failure when `option_has_scope()` is invoked. This issue miraculously doesn't exist in release builds since the assertion is skipped and `(get/set)_option_value_for` returns if there is an error set, but that is not the intended location for that error to be caught. Solution: Make `validate_option_value_args()` return `FAIL` if there is an error set, which causes the API option functions to return early instead of trying to get/set an invalid option. --- src/nvim/api/options.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/api') diff --git a/src/nvim/api/options.c b/src/nvim/api/options.c index 3289daeb6f..8fd9904f7a 100644 --- a/src/nvim/api/options.c +++ b/src/nvim/api/options.c @@ -95,7 +95,7 @@ static int validate_option_value_args(Dict(option) *opts, char *name, OptIndex * } } - return OK; + return ERROR_SET(err) ? FAIL : OK; #undef HAS_KEY_X } -- cgit