Skip to content

Commit 78dc961

Browse files
authored
Merge pull request #72714 from rintaro/macros-bridgedloc-rdar125625879
[ASTGen/Macros] Ensure 'offset' from plugin response is valid
2 parents 44a2661 + 9d336a0 commit 78dc961

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/ASTGen/Sources/ASTGen/PluginHost.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,10 @@ class PluginDiagnosticsEngine {
349349
guard let bufferBaseAddress = exportedSourceFile.pointee.buffer.baseAddress else {
350350
return nil
351351
}
352+
// Ensure 'offset' is within the buffer.
353+
guard offset <= exportedSourceFile.pointee.buffer.count else {
354+
return nil
355+
}
352356
return BridgedSourceLoc(raw: bufferBaseAddress).advanced(by: offset)
353357
}
354358

0 commit comments

Comments
 (0)