summaryrefslogtreecommitdiffstats
path: root/llvm/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
commit6c43f5e5fec87871b978fdd1270feba46731732d (patch)
treefee7f16c0d8054bdb138dfca82e07af1faf84f75 /llvm/lib/Support/FileUtilities.cpp
parent4add7e356f3381fdfa62ff151af4de3054f8b84e (diff)
downloadbcm5719-llvm-6c43f5e5fec87871b978fdd1270feba46731732d.tar.gz
bcm5719-llvm-6c43f5e5fec87871b978fdd1270feba46731732d.zip
Fix crash comparing empty file against nonempty file.
llvm-svn: 19782
Diffstat (limited to 'llvm/lib/Support/FileUtilities.cpp')
-rw-r--r--llvm/lib/Support/FileUtilities.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/Support/FileUtilities.cpp b/llvm/lib/Support/FileUtilities.cpp
index 7ae476b5975..99db439d327 100644
--- a/llvm/lib/Support/FileUtilities.cpp
+++ b/llvm/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
OpenPOWER on IntegriCloud