mirror of
https://github.com/neovim/neovim.git
synced 2025-10-07 02:16:31 +00:00
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.
This commit is contained in:
@@ -261,7 +261,9 @@ Object vim_to_object(typval_T *obj)
|
||||
/// @param obj Object to convert from.
|
||||
/// @param tv Conversion result is placed here. On failure member v_type is
|
||||
/// set to VAR_UNKNOWN (no allocation was made for this variable).
|
||||
/// returns true if conversion is successful, otherwise false.
|
||||
/// @param err Error object.
|
||||
///
|
||||
/// @returns true if conversion is successful, otherwise false.
|
||||
bool object_to_vim(Object obj, typval_T *tv, Error *err)
|
||||
{
|
||||
tv->v_type = VAR_UNKNOWN;
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user