Browse Source

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

David Cole 16 years ago
parent
commit
9578bfc0ef
1 changed files with 3 additions and 2 deletions
  1. 3 2
      Source/kwsys/SystemTools.cxx

+ 3 - 2
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))