[serialization] Don't assert when a module file's length is not 32-bit-aligned.

This won't ever happen naturally, but by either messing with the module file
or asking the compiler to load something that isn't a module at all we could
end up hitting the assert.

<rdar://problem/16274875>

Swift SVN r14902
This commit is contained in:
Jordan Rose
2014-03-11 01:27:34 +00:00
parent 631297d4d2
commit ed80c68cb5
2 changed files with 11 additions and 2 deletions

View File

@@ -128,13 +128,16 @@ validateControlBlock(llvm::BitstreamCursor &cursor,
SerializedModuleLoader::ValidationInfo
SerializedModuleLoader::validateSerializedAST(StringRef data) {
ValidationInfo result = { {}, 0, ModuleStatus::Malformed };
if (data.size() % 4 != 0)
return result;
llvm::BitstreamReader reader(reinterpret_cast<const uint8_t *>(data.begin()),
reinterpret_cast<const uint8_t *>(data.end()));
llvm::BitstreamCursor cursor(reader);
SmallVector<uint64_t, 32> scratch;
ValidationInfo result = { {}, 0, ModuleStatus::Malformed };
if (!checkSignature(cursor) || !enterTopLevelModuleBlock(cursor, false))
return result;