From ccd95a9b668d577871aebd07cc9feb16300eb01d Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sat, 2 Nov 2013 20:57:41 -0700 Subject: [PATCH] fix(lua/name): fix memory leak Signed-off-by: Leonardo de Moura --- src/bindings/lua/name.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/bindings/lua/name.cpp b/src/bindings/lua/name.cpp index 7b449499d..5b247853b 100644 --- a/src/bindings/lua/name.cpp +++ b/src/bindings/lua/name.cpp @@ -29,10 +29,12 @@ static int mk_name(lua_State * L) { new (mem) name(str); } else { lean_assert(nargs == 2); + name tmp; name * prefix; if (lua_isstring(L, 1)) { char const * str = luaL_checkstring(L, 1); - prefix = new name(str); + tmp = name(str); + prefix = &tmp; } else { prefix = static_cast(luaL_checkudata(L, 1, "name.mt")); }