mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[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:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user