diff --git a/src/common/Variant.cpp b/src/common/Variant.cpp index 3a7ba1a11..0682e9f14 100644 --- a/src/common/Variant.cpp +++ b/src/common/Variant.cpp @@ -186,12 +186,13 @@ Variant Variant::fromLua(lua_State *L, int n, std::set *tableSet) case LUA_TTABLE: { bool success = true; - std::unique_ptr> tableSetPtr; + std::set topTableSet; std::vector> *table = new std::vector>(); - // If we had no tables argument, allocate one now, and store it in our unique_ptr + // We can use a pointer to a stack-allocated variable because it's + // never used after the stack-allocated variable is destroyed. if (tableSet == nullptr) - tableSetPtr.reset(tableSet = new std::set); + tableSet = &topTableSet; // Now make sure this table wasn't already serialised const void *tablePointer = lua_topointer(L, n);