[llvm-commits] CVS: llvm/lib/Support/FileUtilities.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sat Jan 22 22:02:53 PST 2005
Changes in directory llvm/lib/Support:
FileUtilities.cpp updated: 1.38 -> 1.39
---
Log message:
Fix crash comparing empty file against nonempty file.
---
Diffs of the changes: (+2 -1)
FileUtilities.cpp | 3 ++-
1 files changed, 2 insertions(+), 1 deletion(-)
Index: llvm/lib/Support/FileUtilities.cpp
diff -u llvm/lib/Support/FileUtilities.cpp:1.38 llvm/lib/Support/FileUtilities.cpp:1.39
--- llvm/lib/Support/FileUtilities.cpp:1.38 Sat Jan 22 21:31:02 2005
+++ llvm/lib/Support/FileUtilities.cpp Sun Jan 23 00:02:40 2005
@@ -93,7 +93,8 @@
// 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
More information about the llvm-commits
mailing list