diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2011-09-15 14:09:02 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2011-09-15 14:09:02 -0300 |
commit | 68ce878292cf7c571b8bc20f567e462ae62d859d (patch) | |
tree | c7ad793a96d65efef8e9a7893bfb9b086c483021 | |
parent | 500336efd087c02d663797e6d1c256f65e281f05 (diff) | |
download | lua-68ce878292cf7c571b8bc20f567e462ae62d859d.tar.gz lua-68ce878292cf7c571b8bc20f567e462ae62d859d.tar.bz2 lua-68ce878292cf7c571b8bc20f567e462ae62d859d.zip |
cannot compute 'mainposition' before checking whether key is nil
-rw-r--r-- | ltable.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltable.c,v 2.61 2011/08/09 20:58:29 roberto Exp roberto $ | 2 | ** $Id: ltable.c,v 2.62 2011/08/17 20:26:47 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 | */ |
@@ -402,10 +402,11 @@ static Node *getfreepos (Table *t) { | |||
402 | ** position), new key goes to an empty position. | 402 | ** position), new key goes to an empty position. |
403 | */ | 403 | */ |
404 | TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key) { | 404 | TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key) { |
405 | Node *mp = mainposition(t, key); | 405 | Node *mp; |
406 | if (ttisnil(key)) luaG_runerror(L, "table index is nil"); | 406 | if (ttisnil(key)) luaG_runerror(L, "table index is nil"); |
407 | else if (ttisnumber(key) && luai_numisnan(L, nvalue(key))) | 407 | else if (ttisnumber(key) && luai_numisnan(L, nvalue(key))) |
408 | luaG_runerror(L, "table index is NaN"); | 408 | luaG_runerror(L, "table index is NaN"); |
409 | mp = mainposition(t, key); | ||
409 | if (!ttisnil(gval(mp)) || isdummy(mp)) { /* main position is taken? */ | 410 | if (!ttisnil(gval(mp)) || isdummy(mp)) { /* main position is taken? */ |
410 | Node *othern; | 411 | Node *othern; |
411 | Node *n = getfreepos(t); /* get a free place */ | 412 | Node *n = getfreepos(t); /* get a free place */ |