summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bcinfo/Wrap/bitcode_wrapperer.cpp7
-rw-r--r--include/bcinfo/Wrap/bitcode_wrapperer.h8
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.