mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Serialization] Sanity-check alignment of AST data.
Somewhere--and I forget where--either the LLVM bitcode system or the OnDiskHashTable implementation depends on 32-bit alignment being preserved. We had thought that only alignment /from the start of the stream/ mattered, but it looks like the whole data section has to be 32-bit-aligned. <rdar://problem/17814086> Swift SVN r20599
This commit is contained in:
@@ -139,7 +139,9 @@ SerializedModuleLoader::ValidationInfo
|
||||
SerializedModuleLoader::validateSerializedAST(StringRef data) {
|
||||
ValidationInfo result = { {}, 0, ModuleStatus::Malformed };
|
||||
|
||||
if (data.size() % 4 != 0)
|
||||
// Check 32-bit alignment.
|
||||
if (data.size() % 4 != 0 ||
|
||||
reinterpret_cast<uintptr_t>(data.data()) % 4 != 0)
|
||||
return result;
|
||||
|
||||
llvm::BitstreamReader reader(reinterpret_cast<const uint8_t *>(data.begin()),
|
||||
|
||||
Reference in New Issue
Block a user