diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-10-19 11:05:11 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-10-19 11:05:11 -0200 |
commit | ed7039024d32778a62fd52a98fe98f3e38133853 (patch) | |
tree | 3c374aa6d13a0be4698f57088287b4ffd0d2b145 /lstrlib.c | |
parent | 5511bf6b9d6018665f5c184c5a464bb8b0aceca5 (diff) | |
download | lua-ed7039024d32778a62fd52a98fe98f3e38133853.tar.gz lua-ed7039024d32778a62fd52a98fe98f3e38133853.tar.bz2 lua-ed7039024d32778a62fd52a98fe98f3e38133853.zip |
avoid some warnings
Diffstat (limited to 'lstrlib.c')
-rw-r--r-- | lstrlib.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstrlib.c,v 1.123 2005/08/26 17:36:32 roberto Exp roberto $ | 2 | ** $Id: lstrlib.c,v 1.124 2005/09/19 13:49:12 roberto Exp roberto $ |
3 | ** Standard library for string operations and pattern-matching | 3 | ** Standard library for string operations and pattern-matching |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -111,7 +111,9 @@ static int str_byte (lua_State *L) { | |||
111 | if (posi <= 0) posi = 1; | 111 | if (posi <= 0) posi = 1; |
112 | if ((size_t)pose > l) pose = l; | 112 | if ((size_t)pose > l) pose = l; |
113 | if (posi > pose) return 0; /* empty interval; return no values */ | 113 | if (posi > pose) return 0; /* empty interval; return no values */ |
114 | n = pose - posi + 1; | 114 | n = (int)(pose - posi + 1); |
115 | if (posi + n <= pose) /* overflow? */ | ||
116 | luaL_error(L, "string slice too long"); | ||
115 | luaL_checkstack(L, n, "string slice too long"); | 117 | luaL_checkstack(L, n, "string slice too long"); |
116 | for (i=0; i<n; i++) | 118 | for (i=0; i<n; i++) |
117 | lua_pushinteger(L, uchar(s[posi+i-1])); | 119 | lua_pushinteger(L, uchar(s[posi+i-1])); |