From 907630b04c27a130ef00494c42a78dc4eed6e593 Mon Sep 17 00:00:00 2001 From: Bart van Strien Date: Wed, 30 Aug 2017 18:57:12 +0200 Subject: [PATCH] Fix cycle detection It used to detect duplicates, not just cycles. --HG-- branch : minor --- src/common/Variant.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/common/Variant.cpp b/src/common/Variant.cpp index 3e71b5e9e..11c34a8e2 100644 --- a/src/common/Variant.cpp +++ b/src/common/Variant.cpp @@ -198,9 +198,9 @@ Variant Variant::fromLua(lua_State *L, int n, std::set *tableSet) tableSetPtr.reset(tableSet = new std::set); // 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(table); + auto result = tableSet->insert(tablePointer); if (!result.second) // insertion failed throw love::Exception("Cycle detected in table"); } @@ -224,6 +224,9 @@ Variant Variant::fromLua(lua_State *L, int n, std::set *tableSet) } } + // And remove the table from the set again + tableSet->erase(tablePointer); + if (success) return Variant(table); else