diff --git a/lauxlib.c b/lauxlib.c index 900f14b9..84f13cb4 100644 --- a/lauxlib.c +++ b/lauxlib.c @@ -1,5 +1,5 @@ /* -** $Id: lauxlib.c,v 1.152 2005/09/06 17:20:11 roberto Exp roberto $ +** $Id: lauxlib.c,v 1.153 2005/10/03 14:36:45 roberto Exp roberto $ ** Auxiliary functions for building Lua libraries ** See Copyright Notice in lua.h */ @@ -305,7 +305,7 @@ LUALIB_API int luaL_getn (lua_State *L, int t) { if ((n = checkint(L, 2)) >= 0) return n; lua_getfield(L, t, "n"); /* else try t.n */ if ((n = checkint(L, 1)) >= 0) return n; - return lua_objlen(L, t); + return (int)lua_objlen(L, t); } #endif @@ -470,7 +470,7 @@ LUALIB_API int luaL_ref (lua_State *L, int t) { lua_rawseti(L, t, FREELIST_REF); /* (t[FREELIST_REF] = t[ref]) */ } else { /* no free elements */ - ref = lua_objlen(L, t); + ref = (int)lua_objlen(L, t); ref++; /* create new reference */ } lua_rawseti(L, t, ref); diff --git a/ldblib.c b/ldblib.c index 3ee8631b..6aad5751 100644 --- a/ldblib.c +++ b/ldblib.c @@ -1,5 +1,5 @@ /* -** $Id: ldblib.c,v 1.100 2005/08/15 14:12:32 roberto Exp roberto $ +** $Id: ldblib.c,v 1.101 2005/08/26 17:36:32 roberto Exp roberto $ ** Interface from Lua to its debug API ** See Copyright Notice in lua.h */ @@ -319,7 +319,7 @@ static int db_errorfb (lua_State *L) { lua_State *L1 = getthread(L, &arg); lua_Debug ar; if (lua_isnumber(L, arg+2)) { - level = lua_tointeger(L, arg+2); + level = (int)lua_tointeger(L, arg+2); lua_pop(L, 1); } else diff --git a/liolib.c b/liolib.c index e723b656..eb4df497 100644 --- a/liolib.c +++ b/liolib.c @@ -1,5 +1,5 @@ /* -** $Id: liolib.c,v 2.67 2005/08/26 17:36:32 roberto Exp roberto $ +** $Id: liolib.c,v 2.68 2005/10/14 16:24:11 roberto Exp roberto $ ** Standard I/O (and system) library ** See Copyright Notice in lua.h */ @@ -424,7 +424,7 @@ static int f_seek (lua_State *L) { static const char *const modenames[] = {"set", "cur", "end", NULL}; FILE *f = tofile(L); int op = luaL_checkoption(L, 2, "cur", modenames); - lua_Integer offset = luaL_optinteger(L, 3, 0); + long offset = luaL_optlong(L, 3, 0); op = fseek(f, offset, mode[op]); if (op) return pushresult(L, 0, NULL); /* error */ diff --git a/lstrlib.c b/lstrlib.c index faf0f0f4..de01678b 100644 --- a/lstrlib.c +++ b/lstrlib.c @@ -1,5 +1,5 @@ /* -** $Id: lstrlib.c,v 1.123 2005/08/26 17:36:32 roberto Exp roberto $ +** $Id: lstrlib.c,v 1.124 2005/09/19 13:49:12 roberto Exp roberto $ ** Standard library for string operations and pattern-matching ** See Copyright Notice in lua.h */ @@ -111,7 +111,9 @@ static int str_byte (lua_State *L) { if (posi <= 0) posi = 1; if ((size_t)pose > l) pose = l; if (posi > pose) return 0; /* empty interval; return no values */ - n = pose - posi + 1; + n = (int)(pose - posi + 1); + if (posi + n <= pose) /* overflow? */ + luaL_error(L, "string slice too long"); luaL_checkstack(L, n, "string slice too long"); for (i=0; i