From c8e45366b9d0914eb17f759e0bfa7829fd419857 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 29 Apr 2022 17:30:45 +0800 Subject: fix(mappings): fix double-free when unmapping simplifiable Lua mapping --- src/nvim/getchar.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 58daa9631a..eb78317ee7 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -3299,7 +3299,9 @@ int buf_do_map(int maptype, MapArguments *args, int mode, bool is_abbrev, buf_T XFREE_CLEAR(mp->m_str); XFREE_CLEAR(mp->m_orig_str); XFREE_CLEAR(mp->m_desc); - NLUA_CLEAR_REF(mp->m_luaref); + if (!mp->m_simplified) { + NLUA_CLEAR_REF(mp->m_luaref); + } mp->m_str = vim_strsave(rhs); mp->m_orig_str = vim_strsave(orig_rhs); @@ -3500,7 +3502,9 @@ static void mapblock_free(mapblock_T **mpp) mp = *mpp; xfree(mp->m_keys); - NLUA_CLEAR_REF(mp->m_luaref); + if (!mp->m_simplified) { + NLUA_CLEAR_REF(mp->m_luaref); + } XFREE_CLEAR(mp->m_str); XFREE_CLEAR(mp->m_orig_str); XFREE_CLEAR(mp->m_desc); -- cgit