Skip to content

Commit

Permalink
Fix off-by-one issue in sim.parts, fixes #678
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob1 committed Sep 15, 2019
1 parent 66ef37e commit 28d5345
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/lua/LuaScriptInterface.cpp
Expand Up @@ -1893,11 +1893,9 @@ int PartsClosure(lua_State * l)
int i = lua_tointeger(l, lua_upvalueindex(1));
do
{
if(i>=NPART)
if (++i >= NPART)
return 0;
else
i++;
} while(!luacon_sim->parts[i].type);
} while (!luacon_sim->parts[i].type);
lua_pushnumber(l, i);
lua_replace(l, lua_upvalueindex(1));
lua_pushnumber(l, i);
Expand Down

0 comments on commit 28d5345

Please sign in to comment.