summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastien Barre <sebastien.barre@kitware.com>2002-04-15 12:48:39 (GMT)
committerSebastien Barre <sebastien.barre@kitware.com>2002-04-15 12:48:39 (GMT)
commita89dd1fbaf7bf430321f86737417ae6c42fb6de4 (patch)
tree7c1e42b04b40966aada52f16b07d76f97bcae1d3
parent36189ce2a87f24617d22ee52cde7ad143577f805 (diff)
downloadCMake-a89dd1fbaf7bf430321f86737417ae6c42fb6de4.zip
CMake-a89dd1fbaf7bf430321f86737417ae6c42fb6de4.tar.gz
CMake-a89dd1fbaf7bf430321f86737417ae6c42fb6de4.tar.bz2
ENH: FilesDiffer checks for 0 byte files
-rw-r--r--Source/cmSystemTools.cxx17
1 files changed, 5 insertions, 12 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 25bea73..a0db02c 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -969,6 +969,11 @@ bool cmSystemTools::FilesDiffer(const char* source,
return true;
}
+ if(statSource.st_size == 0)
+ {
+ return false;
+ }
+
#if defined(_WIN32) || defined(__CYGWIN__)
std::ifstream finSource(source,
std::ios::binary | std::ios::in);
@@ -984,19 +989,7 @@ bool cmSystemTools::FilesDiffer(const char* source,
}
char* source_buf = new char[statSource.st_size];
- if (!source_buf)
- {
- cmSystemTools::Error("FilesDiffer failed to allocate memory for source!");
- return false;
- }
-
char* dest_buf = new char[statSource.st_size];
- if (!dest_buf)
- {
- cmSystemTools::Error("FilesDiffer failed to allocate memory for dest!");
- delete [] source_buf;
- return false;
- }
finSource.read(source_buf, statSource.st_size);
finDestination.read(dest_buf, statSource.st_size);