[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:
Jordan Rose
2014-07-27 00:47:39 +00:00
parent 5c1e9d7d36
commit 6d7d141b09

View File

@@ -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()),