Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1f8423e

Browse files
committed
fix(maparg): remove double allocation
ASAN doesn't catch this, as it is referenced by the garbage collector.Also remove a condition that is always true.
1 parent8740e0b commit1f8423e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

‎src/nvim/mapping.c‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2008,8 +2008,7 @@ static Dictionary mapblock_fill_dict(const mapblock_T *const mp, const char *lhs
20082008
FUNC_ATTR_NONNULL_ARG(1)
20092009
{
20102010
Dictionarydict=ARRAY_DICT_INIT;
2011-
char*constlhs=str2special_save((constchar*)mp->m_keys,
2012-
compatible, !compatible);
2011+
char*constlhs=str2special_save((constchar*)mp->m_keys,compatible, !compatible);
20132012
char*constmapmode=map_mode_to_chars(mp->m_mode);
20142013
varnumber_Tnoremap_value;
20152014

@@ -2122,13 +2121,15 @@ static void get_maparg(typval_T *argvars, typval_T *rettv, int exact)
21222121
}
21232122
}else {
21242123
// Return a dictionary.
2125-
tv_dict_alloc_ret(rettv);
21262124
if (mp!=NULL&& (rhs!=NULL||rhs_lua!=LUA_NOREF)) {
21272125
Dictionarydict=mapblock_fill_dict(mp,
21282126
did_simplify ? (char*)keys_simplified :NULL,
21292127
buffer_local, true);
21302128
(void)object_to_vim(DICTIONARY_OBJ(dict),rettv,NULL);
21312129
api_free_dictionary(dict);
2130+
}else {
2131+
// Return an empty dictionary.
2132+
tv_dict_alloc_ret(rettv);
21322133
}
21332134
}
21342135

@@ -2164,12 +2165,12 @@ void f_mapset(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
21642165
Objectcallback_obj=vim_to_object(&callback_di->di_tv);
21652166
if (callback_obj.type==kObjectTypeLuaRef&&callback_obj.data.luaref!=LUA_NOREF) {
21662167
rhs_lua=callback_obj.data.luaref;
2167-
orig_rhs="";// need non-NULL for strlen()
2168+
orig_rhs="";
21682169
callback_obj.data.luaref=LUA_NOREF;
21692170
}
21702171
api_free_object(callback_obj);
21712172
}
2172-
if (lhs==NULL||lhsraw==NULL||(orig_rhs==NULL&&rhs_lua==LUA_NOREF)) {
2173+
if (lhs==NULL||lhsraw==NULL||orig_rhs==NULL) {
21732174
emsg(_("E460: entries missing in mapset() dict argument"));
21742175
api_free_luaref(rhs_lua);
21752176
return;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp