aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorglacambre <code@lacamb.re>2021-05-25 07:06:50 +0200
committerglacambre <code@lacamb.re>2021-05-26 07:07:11 +0200
commit0c8454f5bc5c40a2d2926f4b630a8519731fd7ae (patch)
treeee13494456b38ee08f5bd1f3fffd82b7bfb123ff
parent75992f2ad9189a5f39b3e2ae7962c68d3af815a4 (diff)
downloadrneovim-0c8454f5bc5c40a2d2926f4b630a8519731fd7ae.tar.gz
rneovim-0c8454f5bc5c40a2d2926f4b630a8519731fd7ae.tar.bz2
rneovim-0c8454f5bc5c40a2d2926f4b630a8519731fd7ae.zip
Fix crash on `:echo get_all_options_info()`
Iterating over PARAM_COUNT is wrong as PARAM_COUNT also counts the last element of the options array, which has a NULL fullname in order to signal the end of the array.
-rw-r--r--src/nvim/option.c2
-rw-r--r--test/functional/api/vim_spec.lua4
2 files changed, 5 insertions, 1 deletions
diff --git a/src/nvim/option.c b/src/nvim/option.c
index ad481af7fa..8f8a57caf2 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -7700,7 +7700,7 @@ Dictionary get_vimoption(String name, Error *err)
Dictionary get_all_vimoptions(void)
{
Dictionary retval = ARRAY_DICT_INIT;
- for (size_t i = 0; i < PARAM_COUNT; i++) {
+ for (size_t i = 0; options[i].fullname != NULL; i++) {
Dictionary opt_dict = vimoption2dict(&options[i]);
PUT(retval, options[i].fullname, DICTIONARY_OBJ(opt_dict));
}
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index 6926022ee3..0c0f610401 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -1986,6 +1986,10 @@ describe('API', function()
eq(meths.get_option_info'winhighlight', options_info.winhighlight)
end)
+
+ it('should not crash when echoed', function()
+ meths.exec("echo nvim_get_all_options_info()", true)
+ end)
end)
describe('nvim_get_option_info', function()