aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2011-09-15 14:09:02 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2011-09-15 14:09:02 -0300
commit68ce878292cf7c571b8bc20f567e462ae62d859d (patch)
treec7ad793a96d65efef8e9a7893bfb9b086c483021
parent500336efd087c02d663797e6d1c256f65e281f05 (diff)
downloadlua-68ce878292cf7c571b8bc20f567e462ae62d859d.tar.gz
lua-68ce878292cf7c571b8bc20f567e462ae62d859d.tar.bz2
lua-68ce878292cf7c571b8bc20f567e462ae62d859d.zip
cannot compute 'mainposition' before checking whether key is nil
-rw-r--r--ltable.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/ltable.c b/ltable.c
index 1bfe616c..2ac57a07 100644
--- a/ltable.c
+++ b/ltable.c
@@ -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*/
404TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key) { 404TValue *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 */