mirror of
https://github.com/love2d/love.git
synced 2026-08-16 16:20:42 +02:00
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:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user