Skip to content

Commit

Permalink
Limit State.Top >= 0
Browse files Browse the repository at this point in the history
Probably not an issue in practice,
but want to be safe for strange stacks.
  • Loading branch information
zombiezen committed Dec 9, 2024
1 parent e7d59e9 commit b29b644
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion internal/mylua/lua.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func (l *State) Top() int {
if len(l.callStack) == 0 {
return 0
}
return len(l.stack) - l.frame().registerStart()
return max(len(l.stack)-l.frame().registerStart(), 0)
}

// SetTop accepts any index, or 0, and sets the stack top to this index.
Expand Down

0 comments on commit b29b644

Please sign in to comment.