mmap of a zero length file returns null on some platforms, so hack around it.
llvm-svn: 13121
diff --git a/llvm/utils/fpcmp/fpcmp.cpp b/llvm/utils/fpcmp/fpcmp.cpp
index 6f8298e..7e472d4 100644
--- a/llvm/utils/fpcmp/fpcmp.cpp
+++ b/llvm/utils/fpcmp/fpcmp.cpp
@@ -50,6 +50,12 @@
std::cerr << "Error: cannot open file '" << Filename << "'\n";
exit(2);
}
+
+ // If mmap decided that the files were empty, it might have returned a
+ // null pointer. If so, make a new, fake pointer -- it shouldn't matter
+ // what it contains, because Len is 0, and it should never be read.
+ if (BufPtr == 0 && Len == 0)
+ BufPtr = new char[1];
}
static bool isNumberChar(char C) {