Skip to content

Commit

Permalink
Fix unaligned access bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
DimaRU committed Feb 16, 2024
1 parent 563e7ab commit 24acbd6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions Plugins/Msg2swiftCmdPlugin/plugin.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import PackagePlugin
import Foundation

@main
struct Msg2swiftCmdPlugin: CommandPlugin {
func performCommand(context: PluginContext, arguments: [String]) throws {
let uicTool = try context.tool(named: "msg2swift").path
let process = try Process.run(URL(fileURLWithPath: uicTool.string), arguments: arguments)
process.waitUntilExit()

guard
process.terminationReason == .exit,
process.terminationStatus == 0
else {
let problem = "\(process.terminationReason):\(process.terminationStatus)"
Diagnostics.error("msg2swift invocation failed: \(problem)")
return
}
}
}
2 changes: 1 addition & 1 deletion Sources/CDRCodable/Decoder/CDRDecoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ extension DataStore {
defer {
cursor = cursor.advanced(by: stride)
}
return data.withUnsafeBytes{ $0.load(fromByteOffset: cursor - beginIndex, as: T.self) }
return data.withUnsafeBytes{ $0.loadUnaligned(fromByteOffset: cursor - beginIndex, as: T.self) }
}

@inline(__always)
Expand Down

0 comments on commit 24acbd6

Please sign in to comment.