Evan implemented this.
[oota-llvm.git] / lib / Archive / ArchiveWriter.cpp
index f5c412609ac8dbc3e75f8fa2effc6c29e0e69752..04cc981f79608dbaa2dfb29848f0bf149c9875df 100644 (file)
@@ -47,11 +47,12 @@ inline unsigned numVbrBytes(unsigned num) {
   // small ones and four for large ones. We expect this to access file offsets
   // in the 2^10 to 2^24 range and symbol lengths in the 2^0 to 2^8 range,
   // so this approach is reasonable.
-  if (num < 1<<14)
+  if (num < 1<<14) {
     if (num < 1<<7)
       return 1;
     else
       return 2;
+  }
   if (num < 1<<21)
     return 3;
 
@@ -347,7 +348,7 @@ Archive::writeToDisk(bool CreateSymbolTable, bool TruncateNames, bool Compress,
 {
   // Make sure they haven't opened up the file, not loaded it,
   // but are now trying to write it which would wipe out the file.
-  if (members.empty() && mapfile->size() > 8) {
+  if (members.empty() && mapfile && mapfile->size() > 8) {
     if (ErrMsg)
       *ErrMsg = "Can't write an archive not opened for writing";
     return true;