Check infile arguments for BitcodeWrapperer.

It would be better to use a const reference for infile, but unfortunately, we
must mutate it during the lifetime of BitcodeWrapperer - Seek() is the
primary issue here. Since we don't want to use a non-const reference, we
instead insert appropriate NULL checks into the various functions where
infile is used.

Change-Id: Ic408c9dba684b57237cc8e29fff61c103161f7b3
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 @@
 }
 
 bool BitcodeWrapperer::Seek(uint32_t pos) {
-  if (infile_->Seek(pos)) {
+  if (infile_ != NULL && infile_->Seek(pos)) {
     ClearBuffer();
     return true;
   }
@@ -131,6 +131,11 @@
     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 @@
   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.