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...

This commit is contained in:
David Cole 2009-10-16 11:43:05 -04:00
parent 023889cb2c
commit 9578bfc0ef
1 changed files with 3 additions and 2 deletions

View File

@ -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))