From 2372567a6e7a036e624b324dea9904825ad0de3f Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sat, 30 Nov 2013 00:34:38 -0800 Subject: [PATCH] fix(util/luaref): warnings produced by valgrind Signed-off-by: Leonardo de Moura --- src/util/luaref.cpp | 2 +- src/util/luaref.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util/luaref.cpp b/src/util/luaref.cpp index d88053fc6..1549e768f 100644 --- a/src/util/luaref.cpp +++ b/src/util/luaref.cpp @@ -42,7 +42,7 @@ void luaref::release() { } luaref & luaref::operator=(luaref const & r) { - if (m_ref == r.m_ref) + if (m_state != nullptr && r.m_state != nullptr && m_ref == r.m_ref) return *this; if (m_state) luaL_unref(m_state, LUA_REGISTRYINDEX, m_ref); diff --git a/src/util/luaref.h b/src/util/luaref.h index 6b9eaab84..ebbf9e5eb 100644 --- a/src/util/luaref.h +++ b/src/util/luaref.h @@ -15,7 +15,7 @@ class luaref { lua_State * m_state; int m_ref; public: - luaref():m_state(nullptr) {} + luaref():m_state(nullptr), m_ref(0) {} /** \brief Create a reference to the Lua object at position \c i on \c L stack. */