Skip to content

Fix InternalScreen bounds checks#284

Merged
rockorager merged 2 commits intorockorager:mainfrom
dyxushuai:fix/internal-screen-bounds
Dec 28, 2025
Merged

Fix InternalScreen bounds checks#284
rockorager merged 2 commits intorockorager:mainfrom
dyxushuai:fix/internal-screen-bounds

Conversation

@dyxushuai
Copy link
Contributor

@dyxushuai dyxushuai commented Dec 28, 2025

Problem

InternalScreen bounds checks used strict < comparisons. This lets width == col or height == row pass, which can alias the next row (for width == col) or hit the bounds assert on the last row.

Fix

  • Use self.width <= col / self.height <= row checks for read/write.
  • Add a test that covers out-of-bounds access at col == width.

Tests

  • zig test src/InternalScreen.zig

Copilot AI review requested due to automatic review settings December 28, 2025 12:32
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes incorrect bounds checking in InternalScreen that allowed out-of-bounds column and row access to pass through, potentially causing memory aliasing or assertion failures.

  • Changed bounds check conditions from self.width < col to col >= self.width (and equivalent for rows) to correctly reject boundary values
  • Added a test case to verify that writes at col == width are properly rejected and don't corrupt adjacent cells

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@rockorager rockorager merged commit 90cfa3c into rockorager:main Dec 28, 2025
4 checks passed
@rockorager
Copy link
Owner

Thanks!

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.

2 participants