diff options
author | Karl Schimpf <kschimpf@google.com> | 2013-06-13 13:12:03 -0700 |
---|---|---|
committer | Karl Schimpf <kschimpf@google.com> | 2013-06-13 13:12:03 -0700 |
commit | 5d2171152d8441be311af367276e7e016877c05c (patch) | |
tree | e43213eb4b12676133ece44038cf5c66265b67a9 /lib | |
parent | dfb5a31ae3d5c3ec9db280941422dc4160d0822d (diff) |
Fix reading of headers when using a streamable memory object.
Fixes bug where we computed the length of fields buffer on the size of a pointer, rather then the actual length of the field.
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3485
R=dschuff@chromium.org
Review URL: https://codereview.chromium.org/17003002
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Bitcode/NaCl/Reader/NaClBitcodeHeader.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/Bitcode/NaCl/Reader/NaClBitcodeHeader.cpp b/lib/Bitcode/NaCl/Reader/NaClBitcodeHeader.cpp index 5193417619..aa73b9cffa 100644 --- a/lib/Bitcode/NaCl/Reader/NaClBitcodeHeader.cpp +++ b/lib/Bitcode/NaCl/Reader/NaClBitcodeHeader.cpp @@ -187,7 +187,7 @@ bool NaClBitcodeHeader::Read(const unsigned char *&BufPtr, return false; } -bool NaClBitcodeHeader::Read(StreamingMemoryObject *Bytes) { +bool NaClBitcodeHeader::Read(StreamableMemoryObject *Bytes) { unsigned NumFields; unsigned NumBytes; { @@ -197,12 +197,14 @@ bool NaClBitcodeHeader::Read(StreamingMemoryObject *Bytes) { return true; } uint8_t *Header = new uint8_t[NumBytes]; - bool results = + bool failed = Bytes->readBytes(2 * WordSize, NumBytes, Header, NULL) || - ReadFields(Header, Header + sizeof(Header), NumFields, NumBytes); + ReadFields(Header, Header + NumBytes, NumFields, NumBytes); delete[] Header; + if (failed) + return true; InstallFields(); - return results; + return false; } NaClBitcodeHeaderField * |