Skip to content

Commit

Permalink
load => loadUnaligned (#6929)
Browse files Browse the repository at this point in the history
This is the potential source of a crash on x86_64 using the rebranch branch of Swift.

rdar://115675736
  • Loading branch information
neonichu authored and MaxDesiatov committed Sep 28, 2023
1 parent c1956bc commit 2d1e4cf
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Sources/PackagePlugin/Plugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ internal struct MessageConnection<TX,RX> where TX: Encodable, RX: Decodable {
}

// Decode the count.
let count = header.withUnsafeBytes{ $0.load(as: UInt64.self).littleEndian }
let count = header.withUnsafeBytes{ $0.loadUnaligned(as: UInt64.self).littleEndian }
guard count >= 2 else {
throw PluginMessageError.invalidPayloadSize
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Workspace/DefaultPluginScriptRunner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ fileprivate extension FileHandle {
guard header.count == 8 else {
throw PluginMessageError.truncatedHeader
}
let length = header.withUnsafeBytes{ $0.load(as: UInt64.self).littleEndian }
let length = header.withUnsafeBytes{ $0.loadUnaligned(as: UInt64.self).littleEndian }
guard length >= 2 else {
throw PluginMessageError.invalidPayloadSize
}
Expand Down

0 comments on commit 2d1e4cf

Please sign in to comment.