Skip to content

Fix being able to delete locals and WatchWindow::selectedRow becoming negative#220

Merged
nakst merged 2 commits into
nakst:masterfrom
elvnh:fix-deleting-locals
Jun 9, 2026
Merged

Fix being able to delete locals and WatchWindow::selectedRow becoming negative#220
nakst merged 2 commits into
nakst:masterfrom
elvnh:fix-deleting-locals

Conversation

@elvnh

@elvnh elvnh commented Jun 5, 2026

Copy link
Copy Markdown

This pull requests fixes #219, which consists of two issues.

First, the user is able to delete rows from the locals window, which seems unintended. To fix this, a check is inserted that ensures that the delete key only deletes rows if the affected window is a normal watch window, not a locals window.

If this feature was intended, I apologize.

Secondly, when deleting rows from the locals window, the index variable WatchWindow::selectedRow could become negative. This was due to assigning to it the result of WatchLastRow(), which could return -1 if both WatchWindow members rows.Length() and extraRows were equal to 0. As this index was only checked for inequality to rows.Length() when deleting, an out of bounds array access was performed.

This seems to only have been a problem when able to delete from the locals window, as otherwise extraRows is not 0. If the behaviour of deleting from the locals window is intended, this fixes a crash. And even it's not intended, ensuring the variable doesn't go negative is probably a good idea.

Thanks for making a great program.

elvnh added 2 commits June 5, 2026 21:39
If there are currently no elements in WatchWindow::rows and
WatchWindow::extraRows is equal to 0, WatchLastRow() will return -1. This causes
selectedRow to become -1.

Since bounds checks only check if selectedRows != rows.Length(), such checks now
pass. This in turn causes out bounds accesses.

This seems to currently only be a problem when deleting variables from the
locals window.
Insert a check when handling the delete key being hit that the active watch
window is a normal watch window, not the locals window. Otherwise, the user can
delete rows from the locals window.
@nakst

nakst commented Jun 9, 2026

Copy link
Copy Markdown
Owner

Thank you for the commit!

@nakst nakst merged commit 56c97f6 into nakst:master Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Possible to delete variables from locals (which can also cause crash)

2 participants