diff --git a/security_test.go b/security_test.go index a1741f3..8d4c232 100644 --- a/security_test.go +++ b/security_test.go @@ -170,6 +170,13 @@ func TestCraftedReturnDoesNotExposePoppedHostValues(t *testing.T) { } } +func TestCallWithMoreArgumentsThanRegisters(t *testing.T) { + l := NewState() + if err := DoString(l, `local function noop() end noop(nil, "x", {})`); err != nil { + t.Fatal(err) + } +} + func TestDebugGetHookWithoutExternalHook(t *testing.T) { l := NewState() Require(l, "debug", DebugOpen, true) diff --git a/stack.go b/stack.go index 9ba15b8..2616638 100644 --- a/stack.go +++ b/stack.go @@ -187,7 +187,9 @@ func (l *State) pushLuaFrame(function, base, resultCount int, p *prototype) *cal if l.top > first { first = l.top } - clear(l.stack[first:ci.top]) + if first < ci.top { + clear(l.stack[first:ci.top]) + } l.callInfo = ci l.top = ci.top return ci