From 9578bfc0efe5c2d667c7336e247274f1ad8f0e25 Mon Sep 17 00:00:00 2001 From: David Cole Date: Fri, 16 Oct 2009 11:43:05 -0400 Subject: [PATCH] Fix crash on Windows. If input stream is no good, do not try to read a line from it. Return false and an empty line instead... --- Source/kwsys/SystemTools.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 8ed631593..3c1901863 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -3959,10 +3959,11 @@ bool SystemTools::GetLineFromStream(kwsys_ios::istream& is, line = ""; long leftToRead = sizeLimit; - + // If no characters are read from the stream, the end of file has // been reached. Clear the fail bit just before reading. - while(!haveNewline && + while(is && + !haveNewline && leftToRead != 0 && (is.clear(is.rdstate() & ~kwsys_ios::ios::failbit), is.getline(buffer, bufferSize), is.gcount() > 0))