From a89dd1fbaf7bf430321f86737417ae6c42fb6de4 Mon Sep 17 00:00:00 2001 From: Sebastien Barre Date: Mon, 15 Apr 2002 08:48:39 -0400 Subject: [PATCH] ENH: FilesDiffer checks for 0 byte files --- Source/cmSystemTools.cxx | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 25bea730a..a0db02c6e 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);