From 38d05c10114297a9cc61e77aab0524ed1af9442d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 26 Jan 2008 23:23:09 +0000 Subject: [PATCH] don't fail in wxTransferStreamToFile if file size is exact multiple of 4KB (bug 1835918) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@51392 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/docview.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) 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; }