You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I haven't had a problem with this but the last while check looks buggy. The while loop at the end has a check where the control variable is never changed. Presumably, if it gets there and copied < nresults then it's going to create an endless loop on the L.Push(DynValue.Nil); line.
If it's trying to fill the additional spots with L.Push(DynValue.Nil) does copied need to be incremented in that loop?
protected static void LuaCall(LuaState L, lua_Integer nargs, lua_Integer nresults = LUA_MULTRET)
{
DynValue[] args = L.GetTopArray(nargs);
L.Discard(nargs);
DynValue func = L.Pop();
DynValue ret = L.ExecutionContext.Call(func, args);
if (nresults != 0)
{
if (nresults == -1)
{
nresults = (ret.Type == DataType.Tuple) ? ret.Tuple.Length : 1;
}
DynValue[] vals = (ret.Type == DataType.Tuple) ? ret.Tuple : new DynValue[1] { ret };
int copied = 0;
for (int i = 0; i < vals.Length && copied < nresults; i++, copied++)
{
L.Push(vals[i]);
}
while (copied < nresults)
{
L.Push(DynValue.Nil);
}
}
}
Should the last while loop be:
while (copied < nresults)
{
L.Push(DynValue.Nil);
copied++;
}
The text was updated successfully, but these errors were encountered:
Joy-less
added a commit
to Joy-less/moonsharp
that referenced
this issue
Aug 15, 2023
I haven't had a problem with this but the last while check looks buggy. The
while
loop at the end has a check where the control variable is never changed. Presumably, if it gets there andcopied < nresults
then it's going to create an endless loop on theL.Push(DynValue.Nil);
line.If it's trying to fill the additional spots with
L.Push(DynValue.Nil)
doescopied
need to be incremented in that loop?Should the last while loop be:
The text was updated successfully, but these errors were encountered: