From 07f87b6b2e3b7398908a9036f3455f6f6e0b418c 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/trunk@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 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; } -- 2.45.2