X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e0214f1f25894310d8aa777abd39b40d85b7a3e0..304435501bf40f2311e3df9f350a32a6ea142ddd:/src/common/docview.cpp diff --git a/src/common/docview.cpp b/src/common/docview.cpp index 7f37a56f55..d678ca6b54 100644 --- a/src/common/docview.cpp +++ b/src/common/docview.cpp @@ -2439,15 +2439,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; }