summaryrefslogtreecommitdiff
path: root/utils/fpcmp
diff options
context:
space:
mode:
authorBrian Gaeke <gaeke@uiuc.edu>2004-04-23 17:38:17 +0000
committerBrian Gaeke <gaeke@uiuc.edu>2004-04-23 17:38:17 +0000
commit6893eadc9524de6ade68d720701c238a5b1a8ebf (patch)
tree4abce31587724a661291b61ffd6a59b0bd142dd0 /utils/fpcmp
parentb61fc83ecb75e4b1dd44adc3acbd5559aa882e81 (diff)
downloadllvm-6893eadc9524de6ade68d720701c238a5b1a8ebf.tar.gz
llvm-6893eadc9524de6ade68d720701c238a5b1a8ebf.tar.bz2
llvm-6893eadc9524de6ade68d720701c238a5b1a8ebf.tar.xz
mmap of a zero length file returns null on some platforms, so hack around it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13121 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/fpcmp')
-rw-r--r--utils/fpcmp/fpcmp.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/utils/fpcmp/fpcmp.cpp b/utils/fpcmp/fpcmp.cpp
index 6f8298e5c7..7e472d474f 100644
--- a/utils/fpcmp/fpcmp.cpp
+++ b/utils/fpcmp/fpcmp.cpp
@@ -50,6 +50,12 @@ static void OpenFile(const std::string &Filename, unsigned &Len, char* &BufPtr){
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) {