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
This commit is contained in:
Chris Lattner 2005-01-23 06:02:40 +00:00
parent 9c32d3b798
commit da7e70e058

View File

@ -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