From 511765c734ad06a67a5a7af74a8c4e00d216e1ef Mon Sep 17 00:00:00 2001 From: Jeffrey Quesnelle Date: Wed, 17 Oct 2018 14:29:30 -0400 Subject: [PATCH 1/2] Pop stack element used as argument of lua_topointer --- sol/reference.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/sol/reference.hpp b/sol/reference.hpp index 0693a434..2d26c9c3 100644 --- a/sol/reference.hpp +++ b/sol/reference.hpp @@ -432,6 +432,7 @@ namespace sol { const void* pointer() const noexcept { int si = push(); const void* vp = lua_topointer(lua_state(), -si); + pop(); return vp; } From 2ebbe5de86e6c78972a43ca1e5f3e975ee21f44b Mon Sep 17 00:00:00 2001 From: Jeffrey Quesnelle Date: Wed, 17 Oct 2018 14:40:18 -0400 Subject: [PATCH 2/2] Pop the correct element that was pushed --- sol/reference.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sol/reference.hpp b/sol/reference.hpp index 2d26c9c3..4f517ebf 100644 --- a/sol/reference.hpp +++ b/sol/reference.hpp @@ -432,7 +432,7 @@ namespace sol { const void* pointer() const noexcept { int si = push(); const void* vp = lua_topointer(lua_state(), -si); - pop(); + lua_pop(this->lua_state(), si); return vp; }