Added cycle detection to Variant

We accidentally enabled nested tables previously, and now it errors properly when the tables contain cycles. Before you'd get (or at least I got) a nice lua stack overflow error.

--HG--
branch : minor
This commit is contained in:
Bart van Strien
2017-08-30 13:07:57 +02:00
parent d35f69bcff
commit 5ddc89a033
7 changed files with 44 additions and 18 deletions
+3 -1
View File
@@ -63,7 +63,9 @@ Message *Message::fromLua(lua_State *L, int n)
if (lua_isnoneornil(L, n+i))
break;
vargs.push_back(Variant::fromLua(L, n+i));
luax_catchexcept(L, [&]() {
vargs.push_back(Variant::fromLua(L, n+i));
});
if (vargs.back().getType() == Variant::UNKNOWN)
{
+5 -3
View File
@@ -93,10 +93,12 @@ int w_clear(lua_State *L)
int w_quit(lua_State *L)
{
std::vector<Variant> args = {Variant::fromLua(L, 1)};
luax_catchexcept(L, [&]() {
std::vector<Variant> args = {Variant::fromLua(L, 1)};
StrongRef<Message> m(new Message("quit", args), Acquire::NORETAIN);
instance()->push(m);
StrongRef<Message> m(new Message("quit", args), Acquire::NORETAIN);
instance()->push(m);
});
luax_pushboolean(L, true);
return 1;