[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

@@ -85,6 +85,12 @@ SerializedModuleLoader::loadAST(Module &M, Optional<SourceLoc> diagLoc,
bool isFramework) {
assert(input);
if (input->getBufferSize() % 4 != 0) {
if (diagLoc)
Ctx.Diags.diagnose(*diagLoc, diag::serialization_malformed_module);
return nullptr;
}
std::unique_ptr<ModuleFile> loadedModuleFile;
ModuleStatus err = ModuleFile::load(std::move(input), loadedModuleFile,
isFramework);