fix(treesitter): uv_dlclose after uv_dlerror

(cherry picked from commit 5a54681025)
This commit is contained in:
Horror Proton
2025-01-14 00:43:33 +08:00
committed by github-actions[bot]
parent 2bc5e1be0f
commit 323c43e1c4

View File

@ -67,9 +67,9 @@ static TSLanguage *load_language(lua_State *L, const char *path, const char *lan
{
uv_lib_t lib;
if (uv_dlopen(path, &lib)) {
xstrlcpy(IObuff, uv_dlerror(&lib), sizeof(IObuff));
uv_dlclose(&lib);
luaL_error(L, "Failed to load parser for language '%s': uv_dlopen: %s",
lang_name, uv_dlerror(&lib));
luaL_error(L, "Failed to load parser for language '%s': uv_dlopen: %s", lang_name, IObuff);
}
char symbol_buf[128];
@ -77,8 +77,9 @@ static TSLanguage *load_language(lua_State *L, const char *path, const char *lan
TSLanguage *(*lang_parser)(void);
if (uv_dlsym(&lib, symbol_buf, (void **)&lang_parser)) {
xstrlcpy(IObuff, uv_dlerror(&lib), sizeof(IObuff));
uv_dlclose(&lib);
luaL_error(L, "Failed to load parser: uv_dlsym: %s", uv_dlerror(&lib));
luaL_error(L, "Failed to load parser: uv_dlsym: %s", IObuff);
}
TSLanguage *lang = lang_parser();