From 68ce878292cf7c571b8bc20f567e462ae62d859d Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 15 Sep 2011 14:09:02 -0300 Subject: cannot compute 'mainposition' before checking whether key is nil --- ltable.c | 5 +++-- 1 file 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 @@ /* -** $Id: ltable.c,v 2.61 2011/08/09 20:58:29 roberto Exp roberto $ +** $Id: ltable.c,v 2.62 2011/08/17 20:26:47 roberto Exp roberto $ ** Lua tables (hash) ** See Copyright Notice in lua.h */ @@ -402,10 +402,11 @@ static Node *getfreepos (Table *t) { ** position), new key goes to an empty position. */ TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key) { - Node *mp = mainposition(t, key); + Node *mp; if (ttisnil(key)) luaG_runerror(L, "table index is nil"); else if (ttisnumber(key) && luai_numisnan(L, nvalue(key))) luaG_runerror(L, "table index is NaN"); + mp = mainposition(t, key); if (!ttisnil(gval(mp)) || isdummy(mp)) { /* main position is taken? */ Node *othern; Node *n = getfreepos(t); /* get a free place */ -- cgit v1.2.3-55-g6feb