]> git.saurik.com Git - wxWidgets.git/commitdiff
don't fail in wxTransferStreamToFile if file size is exact multiple of 4KB (bug 1835918)
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 26 Jan 2008 23:23:09 +0000 (23:23 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 26 Jan 2008 23:23:09 +0000 (23:23 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51392 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/docview.cpp

index 7f37a56f550004c905a9ad3929b9ae3cc328b22a..d678ca6b54c3d473fd3ed2d1244baa09ecefe661 100644 (file)
@@ -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;
 }