Skip to content

Commit b29b644

Browse files
committed
Limit State.Top >= 0
Probably not an issue in practice, but want to be safe for strange stacks.
1 parent e7d59e9 commit b29b644

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

internal/mylua/lua.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ func (l *State) Top() int {
193193
if len(l.callStack) == 0 {
194194
return 0
195195
}
196-
return len(l.stack) - l.frame().registerStart()
196+
return max(len(l.stack)-l.frame().registerStart(), 0)
197197
}
198198

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

0 commit comments

Comments
 (0)