mirror of
https://github.com/love2d/love.git
synced 2026-08-20 20:49:54 +02:00
Fix cycle detection
It used to detect duplicates, not just cycles. --HG-- branch : minor
This commit is contained in:
@@ -198,9 +198,9 @@ Variant Variant::fromLua(lua_State *L, int n, std::set<const void*> *tableSet)
|
|||||||
tableSetPtr.reset(tableSet = new std::set<const void*>);
|
tableSetPtr.reset(tableSet = new std::set<const void*>);
|
||||||
|
|
||||||
// Now make sure this table wasn't already serialised
|
// Now make sure this table wasn't already serialised
|
||||||
|
const void *tablePointer = lua_topointer(L, n);
|
||||||
{
|
{
|
||||||
const void *table = lua_topointer(L, n);
|
auto result = tableSet->insert(tablePointer);
|
||||||
auto result = tableSet->insert(table);
|
|
||||||
if (!result.second) // insertion failed
|
if (!result.second) // insertion failed
|
||||||
throw love::Exception("Cycle detected in table");
|
throw love::Exception("Cycle detected in table");
|
||||||
}
|
}
|
||||||
@@ -224,6 +224,9 @@ Variant Variant::fromLua(lua_State *L, int n, std::set<const void*> *tableSet)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// And remove the table from the set again
|
||||||
|
tableSet->erase(tablePointer);
|
||||||
|
|
||||||
if (success)
|
if (success)
|
||||||
return Variant(table);
|
return Variant(table);
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user