diff --git a/VM/src/lobject.h b/VM/src/lobject.h index a3864ce9..70a51923 100644 --- a/VM/src/lobject.h +++ b/VM/src/lobject.h @@ -84,7 +84,6 @@ typedef struct lua_TValue // Internal tags used by the VM #define LU_TAG_ITERATOR LUA_UTAG_LIMIT -#define LU_TAG_COUNT (LU_TAG_ITERATOR+1) /* ** for internal debug only diff --git a/VM/src/lstate.h b/VM/src/lstate.h index 967418ab..808f57b9 100644 --- a/VM/src/lstate.h +++ b/VM/src/lstate.h @@ -197,7 +197,7 @@ typedef struct global_State struct Table* mt[LUA_T_COUNT]; // metatables for basic types TString* ttname[LUA_T_COUNT]; // names for basic types TString* tmname[TM_N]; // array with tag-method names - TString* lightuserdataname[LU_TAG_COUNT]; // names for tagged lightuserdata + TString* lightuserdataname[LUA_LUTAG_LIMIT]; // names for tagged lightuserdata TValue pseudotemp; // storage for temporary values used in pseudo2addr diff --git a/VM/src/ltm.cpp b/VM/src/ltm.cpp index a1838b6a..09c3d824 100644 --- a/VM/src/ltm.cpp +++ b/VM/src/ltm.cpp @@ -131,10 +131,15 @@ const TString* luaT_objtypenamestr(lua_State* L, const TValue* o) } else if (ttislightuserdata(o)) { - const TString* name = L->global->lightuserdataname[lightuserdatatag(o)]; + int tag = lightuserdatatag(o); - if (name) - return name; + if (unsigned(tag) < LUA_LUTAG_LIMIT) + { + const TString* name = L->global->lightuserdataname[tag]; + + if (name) + return name; + } } else if (Table* mt = L->global->mt[ttype(o)]) {