Squashed commit of the following:
commit
5673dcacb025089db520ffcd8e87bf217ee59f8e
Author: Michael Matirko <mmatirko@cisco.com>
Date: Tue Sep 24 13:36:00 2019 -0400
lua: Added move constructor and move assignment operator to Lua::State to fix segv (CSCvn22329)
config += "}";
unsigned max = ThreadConfig::get_instance_max();
-
+ states.reserve(max);
+
for ( unsigned i = 0; i < max; ++i )
{
states.emplace_back(true);
luaL_openlibs(state);
}
-State::State(State&& o) :
- state { std::move(o.state) } { }
+State& State::operator=(State&& o)
+{
+ if (this != &o)
+ {
+ if (state)
+ lua_close(state);
+ state = o.state;
+ o.state = nullptr;
+ }
+ return *this;
+}
+
+State::State(State&& o) noexcept
+{
+ state = o.state;
+ o.state = NULL;
+}
State::~State()
{
State(bool openlibs = true);
~State();
- State(State&) = delete;
+ State(State&) = delete;
+ State& operator=(State&) = delete;
// Enable move constructor
- State(State&& other);
+ State(State&&) noexcept;
+ State& operator=(State&&);
lua_State* get_ptr()
{ return state; }