Skip to content

Commit dbb788a

Browse files
authored
Merge pull request #72771 from rintaro/6.0-macros-bridgedloc-rdar125625879
[6.0][ASTGen/Macros] Ensure 'offset' from plugin response is valid
2 parents 29cade6 + 2d0010a commit dbb788a

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)