Skip to content

Commit

Permalink
check object for take
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongfq committed Aug 25, 2023
1 parent c2cf0f3 commit 06392c4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion frameworks/cclua/src/olua/olua.c
Original file line number Diff line number Diff line change
Expand Up @@ -1534,7 +1534,12 @@ static int l_olua_isa(lua_State *L)
static int l_olua_take(lua_State *L)
{
luaL_checktype(L, 1, LUA_TUSERDATA);
olua_setobjflag(L, 1, OLUA_FLAG_SKIP_GC | OLUA_FLAG_TAKE);
if (olua_hasobjflag(L, 1, OLUA_FLAG_IN_HEAP)) {
olua_setobjflag(L, 1, OLUA_FLAG_SKIP_GC | OLUA_FLAG_TAKE);
} else {
olua_printobj(L, "take error", 1);
luaL_error(L, "'%s' is not created from heap", olua_objstring(L, 1));
}
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion tools/lua-bindings/olua

0 comments on commit 06392c4

Please sign in to comment.