1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00

If the bitcode reader input stream isn't a multiple of 4 bytes, it's more

likely not a bitcode file at all, rather than being a bitcode file which
is truncated. Check for this case and issue a more relevant error message.

llvm-svn: 100156
This commit is contained in:
Dan Gohman 2010-04-02 00:03:51 +00:00
parent 1b646b39e2
commit 5437ff1446

View File

@ -1527,12 +1527,16 @@ bool BitcodeReader::ParseModule() {
bool BitcodeReader::ParseBitcodeInto(Module *M) {
TheModule = 0;
if (Buffer->getBufferSize() & 3)
return Error("Bitcode stream should be a multiple of 4 bytes in length");
unsigned char *BufPtr = (unsigned char *)Buffer->getBufferStart();
unsigned char *BufEnd = BufPtr+Buffer->getBufferSize();
if (Buffer->getBufferSize() & 3) {
if (!isRawBitcode(BufPtr, BufEnd) && !isBitcodeWrapper(BufPtr, BufEnd))
return Error("Invalid bitcode signature");
else
return Error("Bitcode stream should be a multiple of 4 bytes in length");
}
// If we have a wrapper header, parse it and ignore the non-bc file contents.
// The magic number is 0x0B17C0DE stored in little endian.
if (isBitcodeWrapper(BufPtr, BufEnd))