fix(treesitter): free memory on removing parser (#19933)

This fixes the ASAN failure.
This commit is contained in:
zeertzjq 2022-08-25 06:41:04 +08:00 committed by GitHub
parent c545d514df
commit 6b9ff5491d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -216,7 +216,9 @@ int tslua_remove_lang(lua_State *L)
const char *lang_name = luaL_checkstring(L, 1);
bool present = pmap_has(cstr_t)(&langs, lang_name);
if (present) {
char *key = (char *)pmap_key(cstr_t)(&langs, lang_name);
pmap_del(cstr_t)(&langs, lang_name);
xfree(key);
}
lua_pushboolean(L, present);
return 1;