aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lauxlib.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/lauxlib.c b/lauxlib.c
index f5e1a764..8326f384 100644
--- a/lauxlib.c
+++ b/lauxlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lauxlib.c,v 1.175 2008/01/03 17:07:59 roberto Exp roberto $ 2** $Id: lauxlib.c,v 1.176 2008/01/17 16:24:30 roberto Exp roberto $
3** Auxiliary functions for building Lua libraries 3** Auxiliary functions for building Lua libraries
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -165,13 +165,13 @@ LUALIB_API void *luaL_testudata (lua_State *L, int ud, const char *tname) {
165 if (p != NULL) { /* value is a userdata? */ 165 if (p != NULL) { /* value is a userdata? */
166 if (lua_getmetatable(L, ud)) { /* does it have a metatable? */ 166 if (lua_getmetatable(L, ud)) { /* does it have a metatable? */
167 lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get correct metatable */ 167 lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get correct metatable */
168 if (lua_rawequal(L, -1, -2)) { /* does it have the correct mt? */ 168 if (!lua_rawequal(L, -1, -2)) /* not the same? */
169 lua_pop(L, 2); /* remove both metatables */ 169 p = NULL; /* value is a userdata with wrong metatable */
170 return p; 170 lua_pop(L, 2); /* remove both metatables */
171 } 171 return p;
172 } 172 }
173 } 173 }
174 return NULL; /* value is not a userdata of the proper type */ 174 return NULL; /* value is not a userdata with a metatable */
175} 175}
176 176
177 177