fix(lua/name): fix memory leak
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
dbf2d56c77
commit
ccd95a9b66
1 changed files with 3 additions and 1 deletions
|
@ -29,10 +29,12 @@ static int mk_name(lua_State * L) {
|
||||||
new (mem) name(str);
|
new (mem) name(str);
|
||||||
} else {
|
} else {
|
||||||
lean_assert(nargs == 2);
|
lean_assert(nargs == 2);
|
||||||
|
name tmp;
|
||||||
name * prefix;
|
name * prefix;
|
||||||
if (lua_isstring(L, 1)) {
|
if (lua_isstring(L, 1)) {
|
||||||
char const * str = luaL_checkstring(L, 1);
|
char const * str = luaL_checkstring(L, 1);
|
||||||
prefix = new name(str);
|
tmp = name(str);
|
||||||
|
prefix = &tmp;
|
||||||
} else {
|
} else {
|
||||||
prefix = static_cast<name*>(luaL_checkudata(L, 1, "name.mt"));
|
prefix = static_cast<name*>(luaL_checkudata(L, 1, "name.mt"));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue