From 26de78b084f76d13475933f6c3970c0c57e3b2e6 Mon Sep 17 00:00:00 2001 From: mihacooper Date: Fri, 26 Oct 2018 02:22:41 +0300 Subject: [PATCH] Fix race condition in SharedTable (#113) --- src/cpp/shared-table.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cpp/shared-table.cpp b/src/cpp/shared-table.cpp index a4bc48c..6af0d4c 100644 --- a/src/cpp/shared-table.cpp +++ b/src/cpp/shared-table.cpp @@ -280,7 +280,8 @@ SharedTable SharedTable::luaSetMetatable(const sol::stack_object& tbl, const sol stable.ctx_->metatable = GCNull; } - stable.ctx_->metatable = createStoredObject(mt)->gcHandle(); + const auto mtObj = createStoredObject(mt); + stable.ctx_->metatable = mtObj->gcHandle(); stable.ctx_->addReference(stable.ctx_->metatable); return stable;