1
0
mirror of https://github.com/lua/lua synced 2025-03-24 22:52:51 +03:00

lua_objlen should not work for numbers (according to the manual)

This commit is contained in:
Roberto Ierusalimschy 2009-06-17 15:38:54 -03:00
parent ec52149485
commit 14115170bc

9
lapi.c

@ -1,5 +1,5 @@
/*
** $Id: lapi.c,v 2.79 2009/06/15 19:51:31 roberto Exp roberto $
** $Id: lapi.c,v 2.80 2009/06/17 17:52:57 roberto Exp roberto $
** Lua API
** See Copyright Notice in lua.h
*/
@ -357,13 +357,6 @@ LUA_API size_t lua_objlen (lua_State *L, int idx) {
case LUA_TSTRING: return tsvalue(o)->len;
case LUA_TUSERDATA: return uvalue(o)->len;
case LUA_TTABLE: return luaH_getn(hvalue(o));
case LUA_TNUMBER: {
size_t l;
lua_lock(L); /* `luaV_tostring' may create a new string */
l = (luaV_tostring(L, o) ? tsvalue(o)->len : 0);
lua_unlock(L);
return l;
}
default: return 0;
}
}