]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
we guess which versions of Lua need help with luaL_setfuncs, and then supply our...
authorbert hubert <bert.hubert@netherlabs.nl>
Sun, 28 May 2017 08:33:57 +0000 (10:33 +0200)
committerbert hubert <bert.hubert@netherlabs.nl>
Sun, 28 May 2017 20:00:12 +0000 (22:00 +0200)
With this commit, we don't do the trampling, which should close #5348. We can improve on the fix by using the native luaL_setfuncs for LuaJIT 2.1 beta too.

pdns/lua-iputils.cc

index c17c8b9f9ed4862a7d922d5c5b340718e102f89c..ef2ed86bc1f12484f3cde4a62eb7479c86ce4b6b 100644 (file)
@@ -43,7 +43,7 @@ extern "C" {
 /*
 ** Adapted from Lua 5.2.0
 */
-static void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup) {
+static void pdns_luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup) {
   luaL_checkstack(L, nup+1, "too many upvalues");
   for (; l->name != NULL; l++) {  /* fill the table with given functions */
     int i;
@@ -55,6 +55,10 @@ static void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup) {
   }
   lua_pop(L, nup);  /* remove upvalues */
 }
+#else
+static void pdns_luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup) {
+  lual_setfuncs(L, l, nup);
+}
 #endif
 
 
@@ -261,22 +265,22 @@ extern "C" int luaopen_iputils(lua_State* L)
   luaL_newmetatable(L, "iputils.ca");
   lua_pushvalue(L, -1);
   lua_setfield(L, -2, "__index");
-  luaL_setfuncs(L, iputils_ca_methods, 0);
+  pdns_luaL_setfuncs(L, iputils_ca_methods, 0);
 
   luaL_newmetatable(L, "iputils.ipset");
   lua_pushvalue(L, -1);
   lua_setfield(L, -2, "__index");
-  luaL_setfuncs(L, ipset_methods, 0);
+  pdns_luaL_setfuncs(L, ipset_methods, 0);
 
   luaL_newmetatable(L, "iputils.netmask");
   lua_pushvalue(L, -1);
   lua_setfield(L, -2, "__index");
-  luaL_setfuncs(L, iputils_netmask_methods, 0);
+  pdns_luaL_setfuncs(L, iputils_netmask_methods, 0);
 
   luaL_newmetatable(L, "iputils.nmgroup");
   lua_pushvalue(L, -1);
   lua_setfield(L, -2, "__index");
-  luaL_setfuncs(L, iputils_nmgroup_methods, 0);
+  pdns_luaL_setfuncs(L, iputils_nmgroup_methods, 0);
 
 #if LUA_VERSION_NUM < 502
   luaL_register(L, "iputils", iputils);