Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(473)

Unified Diff: lib/Bitcode/NaCl/Reader/NaClBitcodeHeader.cpp

Issue 940243003: PNaCl localmod mods in LLVM to 223109 (local files only) (Closed)
Patch Set: xx Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: lib/Bitcode/NaCl/Reader/NaClBitcodeHeader.cpp
diff --git a/lib/Bitcode/NaCl/Reader/NaClBitcodeHeader.cpp b/lib/Bitcode/NaCl/Reader/NaClBitcodeHeader.cpp
index 47a626e9f694d9cc47bbb45a888d99bed33616a1..6162c24cc93b9918ef1fa41e1156fea9dbd3f01d 100644
--- a/lib/Bitcode/NaCl/Reader/NaClBitcodeHeader.cpp
+++ b/lib/Bitcode/NaCl/Reader/NaClBitcodeHeader.cpp
@@ -14,7 +14,7 @@
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/raw_ostream.h"
-#include "llvm/Support/StreamableMemoryObject.h"
+#include "llvm/Support/StreamingMemoryObject.h"
#include <limits>
#include <cstring>
@@ -190,19 +190,22 @@ bool NaClBitcodeHeader::Read(const unsigned char *&BufPtr,
return false;
}
-bool NaClBitcodeHeader::Read(StreamableMemoryObject *Bytes) {
+bool NaClBitcodeHeader::Read(MemoryObject *Bytes) {
unsigned NumFields;
unsigned NumBytes;
+ // First, read the prefix, which is 2 * WordSize, to determine the
+ // NumBytes and NumFields.
{
unsigned char Buffer[2 * WordSize];
- if (Bytes->readBytes(0, sizeof(Buffer), Buffer))
+ if (Bytes->readBytes(Buffer, sizeof(Buffer), 0) != sizeof(Buffer))
return UnsupportedError("Bitcode read failure");
if (ReadPrefix(Buffer, Buffer + sizeof(Buffer), NumFields, NumBytes))
return true; // ReadPrefix sets UnsupportedMessage
}
+ // Then read the rest, starting after the 2 * WordSize of the prefix.
uint8_t *Header = new uint8_t[NumBytes];
bool failed =
- Bytes->readBytes(2 * WordSize, NumBytes, Header) ||
+ Bytes->readBytes(Header, NumBytes, 2 * WordSize) != NumBytes ||
ReadFields(Header, Header + NumBytes, NumFields, NumBytes);
delete[] Header;
if (failed)

Powered by Google App Engine
This is Rietveld 408576698