aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Support/FileUtilities.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-01-23 06:02:40 +0000
committerChris Lattner <sabre@nondot.org>2005-01-23 06:02:40 +0000
commitda7e70e058108fb444741a721ccfb38d40154e5b (patch)
treefe582b029b55548e004e64e7a374dfab9fbac8c0 /lib/Support/FileUtilities.cpp
parent9c32d3b798dc6caeebe6cea2effe80ca5e84e66e (diff)
downloadexternal_llvm-da7e70e058108fb444741a721ccfb38d40154e5b.zip
external_llvm-da7e70e058108fb444741a721ccfb38d40154e5b.tar.gz
external_llvm-da7e70e058108fb444741a721ccfb38d40154e5b.tar.bz2
Fix crash comparing empty file against nonempty file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19782 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/FileUtilities.cpp')
-rw-r--r--lib/Support/FileUtilities.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/Support/FileUtilities.cpp b/lib/Support/FileUtilities.cpp
index 7ae476b..99db439 100644
--- a/lib/Support/FileUtilities.cpp
+++ b/lib/Support/FileUtilities.cpp
@@ -93,7 +93,8 @@ static bool CompareNumbers(char *&F1P, char *&F2P, char *F1End, char *F2End,
// with a number. Because of this, if needed, we pad the file so that it starts
// and ends with a null character.
static void PadFileIfNeeded(char *&FileStart, char *&FileEnd, char *&FP) {
- if (isNumberChar(FileStart[0]) || isNumberChar(FileEnd[-1])) {
+ if (FileStart-FileEnd < 2 ||
+ isNumberChar(FileStart[0]) || isNumberChar(FileEnd[-1])) {
unsigned FileLen = FileEnd-FileStart;
char *NewFile = new char[FileLen+2];
NewFile[0] = 0; // Add null padding