diff options
author | Stephen Hines <srhines@google.com> | 2012-03-27 19:42:04 -0700 |
---|---|---|
committer | android code review <noreply-gerritcodereview@google.com> | 2012-03-27 19:42:05 -0700 |
commit | 03cfe0e30d65d6e2ecbe6282cec4b20d3be690cc (patch) | |
tree | 049abd47ddf7de366b96a40d7ecc72c091fa3ff0 | |
parent | 0d1bf1af537d62279b58a4bdd8d8c50f293b0a72 (diff) | |
parent | 1ad35fbd78f6965bb59572e1cf6a2223ee767c57 (diff) | |
download | libbcc-tools_r20.tar.gz |
Merge "Check infile arguments for BitcodeWrapperer."android-sdk-adt_r20tools_r20
-rw-r--r-- | bcinfo/Wrap/bitcode_wrapperer.cpp | 7 | ||||
-rw-r--r-- | include/bcinfo/Wrap/bitcode_wrapperer.h | 8 |
2 files changed, 13 insertions, 2 deletions
diff --git a/bcinfo/Wrap/bitcode_wrapperer.cpp b/bcinfo/Wrap/bitcode_wrapperer.cpp index c8b7d26..6638536 100644 --- a/bcinfo/Wrap/bitcode_wrapperer.cpp +++ b/bcinfo/Wrap/bitcode_wrapperer.cpp @@ -95,7 +95,7 @@ void BitcodeWrapperer::ClearBuffer() { } bool BitcodeWrapperer::Seek(uint32_t pos) { - if (infile_->Seek(pos)) { + if (infile_ != NULL && infile_->Seek(pos)) { ClearBuffer(); return true; } @@ -131,6 +131,11 @@ void BitcodeWrapperer::FillBuffer() { buffer_size_ = 0; } + // If we don't have an input, we can't refill the buffer at all. + if (infile_ == NULL) { + return; + } + // Now fill in remaining space. size_t needed = buffer_.size() - buffer_size_; diff --git a/include/bcinfo/Wrap/bitcode_wrapperer.h b/include/bcinfo/Wrap/bitcode_wrapperer.h index 2fbce21..97f6294 100644 --- a/include/bcinfo/Wrap/bitcode_wrapperer.h +++ b/include/bcinfo/Wrap/bitcode_wrapperer.h @@ -101,7 +101,13 @@ class BitcodeWrapperer { void FillBuffer(); // Returns the number of bytes in infile. - off_t GetInFileSize() { return infile_->Size(); } + off_t GetInFileSize() { + if (infile_ != NULL) { + return infile_->Size(); + } else { + return 0; + } + } // Returns the offset of bitcode (i.e. the size of the wrapper header) // if the output file were to be written now. |