Skip to content

[ASTGen/Macros] Ensure 'offset' from plugin response is valid #72714

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
Apr 2, 2024

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Mar 29, 2024

We see some crashes presumably caused by invalid 'offset' returned from macro plugins. Although we haven't been able to find a reproducer, guard not to generate invalid source location by checking 'offfset' is within the buffer length.

rdar://125625879

We see some crashes presumably caused by invalid 'offset' returned from
macro plugins. Although we haven't been able to find a reproducer, guard
not to generate invalid source location by checking 'offfset' is within
the buffer length.

rdar://125625879
@rintaro
Copy link
Member Author

rintaro commented Mar 29, 2024

@swift-ci Please smoke test

@@ -349,6 +349,10 @@ class PluginDiagnosticsEngine {
guard let bufferBaseAddress = exportedSourceFile.pointee.buffer.baseAddress else {
return nil
}
// Ensure 'offset' is within the buffer.
guard offset <= exportedSourceFile.pointee.buffer.count else {
Copy link
Member Author

Choose a reason for hiding this comment

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

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