1
0
mirror of https://github.com/lua/lua.git synced 2025-01-28 06:03:00 +08:00
This commit is contained in:
Roberto Ierusalimschy 2014-08-27 11:59:33 -03:00
parent e401513086
commit 9b25347a67

8
lapi.c
View File

@ -1,5 +1,5 @@
/* /*
** $Id: lapi.c,v 2.233 2014/08/01 17:33:08 roberto Exp roberto $ ** $Id: lapi.c,v 2.234 2014/08/21 20:07:56 roberto Exp roberto $
** Lua API ** Lua API
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -676,7 +676,7 @@ LUA_API void lua_createtable (lua_State *L, int narray, int nrec) {
LUA_API int lua_getmetatable (lua_State *L, int objindex) { LUA_API int lua_getmetatable (lua_State *L, int objindex) {
const TValue *obj; const TValue *obj;
Table *mt = NULL; Table *mt = NULL;
int res; int res = 0;
lua_lock(L); lua_lock(L);
obj = index2addr(L, objindex); obj = index2addr(L, objindex);
switch (ttnov(obj)) { switch (ttnov(obj)) {
@ -690,9 +690,7 @@ LUA_API int lua_getmetatable (lua_State *L, int objindex) {
mt = G(L)->mt[ttnov(obj)]; mt = G(L)->mt[ttnov(obj)];
break; break;
} }
if (mt == NULL) if (mt != NULL) {
res = 0;
else {
sethvalue(L, L->top, mt); sethvalue(L, L->top, mt);
api_incr_top(L); api_incr_top(L);
res = 1; res = 1;