diff options
author | SoniEx2 <endermoneymod@gmail.com> | 2022-04-11 21:54:33 -0300 |
---|---|---|
committer | SoniEx2 <endermoneymod@gmail.com> | 2022-04-21 20:23:35 -0300 |
commit | 5f137d2c81878c41aa3b893fb56b1116bc27bc78 (patch) | |
tree | 2d6eadb2474e2d7b234b3dda9efd7559335adce7 /plugins/lua/lua.c | |
parent | e2cfba040e26927b94a4e311a0a61365a81a41b1 (diff) | |
parent | 133f62806441a5db1156653aa1f077d2e8deeb34 (diff) |
Merge upstream changes
Diffstat (limited to 'plugins/lua/lua.c')
-rw-r--r-- | plugins/lua/lua.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/plugins/lua/lua.c b/plugins/lua/lua.c index d1370eaf..f8f051f4 100644 --- a/plugins/lua/lua.c +++ b/plugins/lua/lua.c @@ -957,16 +957,21 @@ static int api_hexchat_pluginprefs_meta_pairs(lua_State *L) hexchat_plugin *h; if(!script->name) + return luaL_error(L, "cannot use hexchat.pluginprefs before registering with hexchat.register"); dest = lua_newuserdata(L, 4096); + h = script->handle; if(!hexchat_pluginpref_list(h, dest)) strcpy(dest, ""); lua_pushlightuserdata(L, dest); lua_pushlightuserdata(L, dest); lua_pushcclosure(L, api_hexchat_pluginprefs_meta_pairs_closure, 2); - return 1; + lua_insert(L, -2); // Return the userdata (second return value from pairs), + // even though it's not used by the closure (first return + // value from pairs), so that Lua knows not to GC it. + return 2; } static int api_attrs_meta_index(lua_State *L) @@ -1764,4 +1769,3 @@ G_MODULE_EXPORT int hexchat_plugin_deinit(hexchat_plugin *plugin_handle) g_clear_pointer(&expand_buffer, g_free); return 1; } - |