aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCai Rijun (Richard) <1297550+cairijun@users.noreply.github.com>2025-02-11 01:37:36 +0800
committerGitHub <noreply@github.com>2025-02-10 09:37:36 -0800
commitad60b3fb4806c0917010bbe97876c22fb57cabcd (patch)
tree925042c2974797a5c3cfb5698f15762e1cf87c3a /src
parent524cdd35c2ae3babc1824257da523615507e7af9 (diff)
downloadrneovim-ad60b3fb4806c0917010bbe97876c22fb57cabcd.tar.gz
rneovim-ad60b3fb4806c0917010bbe97876c22fb57cabcd.tar.bz2
rneovim-ad60b3fb4806c0917010bbe97876c22fb57cabcd.zip
fix(api): memory leaks in vim.api.nvim_*get_option #32390
Problem: `get_option_value` returns caller owned `Object`s but the corresponding C apis do not marked `FUNC_API_RET_ALLOC` properly. Solution: add `FUNC_API_RET_ALLOC` to the C apis.
Diffstat (limited to 'src')
-rw-r--r--src/nvim/api/deprecated.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/nvim/api/deprecated.c b/src/nvim/api/deprecated.c
index 1d81b21be6..2f29ed38ef 100644
--- a/src/nvim/api/deprecated.c
+++ b/src/nvim/api/deprecated.c
@@ -633,6 +633,7 @@ void nvim_set_option(uint64_t channel_id, String name, Object value, Error *err)
Object nvim_get_option(String name, Error *err)
FUNC_API_SINCE(1)
FUNC_API_DEPRECATED_SINCE(11)
+ FUNC_API_RET_ALLOC
{
return get_option_from(NULL, kOptScopeGlobal, name, err);
}
@@ -647,6 +648,7 @@ Object nvim_get_option(String name, Error *err)
Object nvim_buf_get_option(Buffer buffer, String name, Error *err)
FUNC_API_SINCE(1)
FUNC_API_DEPRECATED_SINCE(11)
+ FUNC_API_RET_ALLOC
{
buf_T *buf = find_buffer_by_handle(buffer, err);
@@ -689,6 +691,7 @@ void nvim_buf_set_option(uint64_t channel_id, Buffer buffer, String name, Object
Object nvim_win_get_option(Window window, String name, Error *err)
FUNC_API_SINCE(1)
FUNC_API_DEPRECATED_SINCE(11)
+ FUNC_API_RET_ALLOC
{
win_T *win = find_window_by_handle(window, err);
@@ -728,7 +731,7 @@ void nvim_win_set_option(uint64_t channel_id, Window window, String name, Object
/// @param name The option name.
/// @param[out] err Details of an error that may have occurred.
///
-/// @return the option value.
+/// @return the option value. Must be freed by caller.
static Object get_option_from(void *from, OptScope scope, String name, Error *err)
{
VALIDATE_S(name.size > 0, "option name", "<empty>", {