Skip to content

Fix a crash when trying to apply in edit that has out of line positions #1798

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 1, 2024

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Oct 31, 2024

LineTable.replace did not actually validate that the edit is in range. This could cause crashes of SourceKit-LSP if the editor is sending us bogus edits. Validate the position, like we do in all the other position conversions and log a fault if the edit is out-of-range.

While fixing this, I found a couple more places where line table accesses were not properly guarded. I migrated them to safe alternatives as well.

rdar://138962353

`LineTable.replace` did not actually validate that the edit is in range. This could cause crashes of SourceKit-LSP if the editor is sending us bogus edits. Validate the position, like we do in all the other position conversions and log a fault if the edit is out-of-range.

While fixing this, I found a couple more places where line table accesses were not properly guarded. I migrated them to safe alternatives as well.

rdar://138962353
@ahoppen
Copy link
Member Author

ahoppen commented Oct 31, 2024

@swift-ci Please test

1 similar comment
@plemarquand
Copy link
Contributor

@swift-ci Please test

@ahoppen ahoppen merged commit 331599e into swiftlang:main Nov 1, 2024
3 checks passed
@ahoppen ahoppen deleted the linetable-crash branch November 1, 2024 19:30
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.

3 participants