mirror of https://github.com/rusefi/lua.git
cannot compute 'mainposition' before checking whether key is nil
This commit is contained in:
parent
500336efd0
commit
68ce878292
5
ltable.c
5
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)
|
** Lua tables (hash)
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -402,10 +402,11 @@ static Node *getfreepos (Table *t) {
|
||||||
** position), new key goes to an empty position.
|
** position), new key goes to an empty position.
|
||||||
*/
|
*/
|
||||||
TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key) {
|
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");
|
if (ttisnil(key)) luaG_runerror(L, "table index is nil");
|
||||||
else if (ttisnumber(key) && luai_numisnan(L, nvalue(key)))
|
else if (ttisnumber(key) && luai_numisnan(L, nvalue(key)))
|
||||||
luaG_runerror(L, "table index is NaN");
|
luaG_runerror(L, "table index is NaN");
|
||||||
|
mp = mainposition(t, key);
|
||||||
if (!ttisnil(gval(mp)) || isdummy(mp)) { /* main position is taken? */
|
if (!ttisnil(gval(mp)) || isdummy(mp)) { /* main position is taken? */
|
||||||
Node *othern;
|
Node *othern;
|
||||||
Node *n = getfreepos(t); /* get a free place */
|
Node *n = getfreepos(t); /* get a free place */
|
||||||
|
|
Loading…
Reference in New Issue