diff --git a/src/common/docview.cpp b/src/common/docview.cpp index 0a15360323..7389f94e4c 100644 --- a/src/common/docview.cpp +++ b/src/common/docview.cpp @@ -2460,15 +2460,22 @@ bool wxTransferStreamToFile(wxInputStream& stream, const wxString& filename) return false; char buf[4096]; - do + for ( ;; ) { stream.Read(buf, WXSIZEOF(buf)); const size_t nRead = stream.LastRead(); - if ( !nRead || !file.Write(buf, nRead) ) + if ( !nRead ) + { + if ( stream.Eof() ) + break; + + return false; + } + + if ( !file.Write(buf, nRead) ) return false; } - while ( !stream.Eof() ); return true; }