aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/vim.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-11-11 10:21:14 +0800
committerGitHub <noreply@github.com>2023-11-11 10:21:14 +0800
commite9b9a86cd5a555943b87f0ba40c4527561c3c124 (patch)
treeb1f2aef3e5e68053a8d2f08206b2c61083e6f6c1 /src/nvim/api/vim.c
parentd1b2a5cf5fa583b556457d34a46ce7b940913a66 (diff)
downloadrneovim-e9b9a86cd5a555943b87f0ba40c4527561c3c124.tar.gz
rneovim-e9b9a86cd5a555943b87f0ba40c4527561c3c124.tar.bz2
rneovim-e9b9a86cd5a555943b87f0ba40c4527561c3c124.zip
fix(context): don't crash on invalid arg to nvim_get_context (#25977)
Note: The crash happens in the second test case when using uninitialized memory, and therefore doesn't happen with ASAN.
Diffstat (limited to 'src/nvim/api/vim.c')
-rw-r--r--src/nvim/api/vim.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index c3c619e206..8446f5b383 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -1402,7 +1402,7 @@ Dictionary nvim_get_context(Dict(context) *opts, Error *err)
/// Sets the current editor state from the given |context| map.
///
/// @param dict |Context| map.
-Object nvim_load_context(Dictionary dict)
+Object nvim_load_context(Dictionary dict, Error *err)
FUNC_API_SINCE(6)
{
Context ctx = CONTEXT_INIT;
@@ -1410,8 +1410,8 @@ Object nvim_load_context(Dictionary dict)
int save_did_emsg = did_emsg;
did_emsg = false;
- ctx_from_dict(dict, &ctx);
- if (!did_emsg) {
+ ctx_from_dict(dict, &ctx, err);
+ if (!ERROR_SET(err)) {
ctx_restore(&ctx, kCtxAll);
}