diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2015-07-04 13:32:34 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2015-07-04 13:32:34 -0300 |
commit | 8950e0c049cc51025d501453b85f501b15c5317a (patch) | |
tree | 6449a25bf4e2a94ead1b25b176a25e6454a41917 | |
parent | 8217e0d4fe4cf80c52328230614ab41cf32f4afe (diff) | |
download | lua-8950e0c049cc51025d501453b85f501b15c5317a.tar.gz lua-8950e0c049cc51025d501453b85f501b15c5317a.tar.bz2 lua-8950e0c049cc51025d501453b85f501b15c5317a.zip |
avoid possibility of subtle arith. overflow
-rw-r--r-- | ltable.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltable.c,v 2.111 2015/06/09 14:21:13 roberto Exp roberto $ | 2 | ** $Id: ltable.c,v 2.112 2015/07/01 17:46:55 roberto Exp roberto $ |
3 | ** Lua tables (hash) | 3 | ** Lua tables (hash) |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -501,7 +501,7 @@ TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key) { | |||
501 | */ | 501 | */ |
502 | const TValue *luaH_getint (Table *t, lua_Integer key) { | 502 | const TValue *luaH_getint (Table *t, lua_Integer key) { |
503 | /* (1 <= key && key <= t->sizearray) */ | 503 | /* (1 <= key && key <= t->sizearray) */ |
504 | if (l_castS2U(key - 1) < t->sizearray) | 504 | if (l_castS2U(key) - 1 < t->sizearray) |
505 | return &t->array[key - 1]; | 505 | return &t->array[key - 1]; |
506 | else { | 506 | else { |
507 | Node *n = hashint(t, key); | 507 | Node *n = hashint(t, key); |