diff options
author | David Cole <david.cole@kitware.com> | 2009-10-16 17:23:52 (GMT) |
---|---|---|
committer | David Cole <david.cole@kitware.com> | 2009-10-16 17:23:52 (GMT) |
commit | 847918b38f4557b541c85fec819b90a3e24c6a94 (patch) | |
tree | 3be6d5a4d4c35d723b49b85d7ff973f3ac08837a /Source/kwsys/SystemTools.cxx | |
parent | 402fa2ceeb769221966481d03ecc9cfdcc2ba13d (diff) | |
download | CMake-847918b38f4557b541c85fec819b90a3e24c6a94.zip CMake-847918b38f4557b541c85fec819b90a3e24c6a94.tar.gz CMake-847918b38f4557b541c85fec819b90a3e24c6a94.tar.bz2 |
Better fix for crash on Windows. This time it will even work on Linux, too. That GetLineFromStream method while loop sure is fussy.
Diffstat (limited to 'Source/kwsys/SystemTools.cxx')
-rw-r--r-- | Source/kwsys/SystemTools.cxx | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 3c19018..a6dee1b 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -3960,10 +3960,22 @@ bool SystemTools::GetLineFromStream(kwsys_ios::istream& is, long leftToRead = sizeLimit; + // Early short circuit return if stream is no good. Just return + // false and the empty line. (Probably means caller tried to + // create a file stream with a non-existent file name...) + // + if(!is) + { + if(has_newline) + { + *has_newline = false; + } + return false; + } + // If no characters are read from the stream, the end of file has // been reached. Clear the fail bit just before reading. - while(is && - !haveNewline && + while(!haveNewline && leftToRead != 0 && (is.clear(is.rdstate() & ~kwsys_ios::ios::failbit), is.getline(buffer, bufferSize), is.gcount() > 0)) |