OLE: Fix SmallBlocksToBigBlocks loop

Ulrich Czekalla ulrich.czekalla at utoronto.ca
Thu Jan 5 11:52:52 CST 2006


This patch updated Storage32Impl_SmallBlocksToBigBlocks so that it stops
copying data when there is nothing left to read.

This fixes the installer reported in bug 4210.

ChangeLog:
    Ulrich Czekalla <ulrich at codeweavers.com>
    Stop copying data when read returns 0 bytes
-------------- next part --------------
Subject: [PATCH] Stop copying data when read returns 0 bytes

---

 dlls/ole32/storage32.c |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)

498244d0a3f1c023843d5c0bf845998171f10f9e
diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c
index c9d696e..cde6526 100644
--- a/dlls/ole32/storage32.c
+++ b/dlls/ole32/storage32.c
@@ -3453,18 +3453,26 @@ BlockChainStream* Storage32Impl_SmallBlo
                                                DEF_SMALL_BLOCK_SIZE,
                                                buffer,
                                                &cbRead);
-    cbTotalRead += cbRead;
+    if (FAILED(successRead))
+        break;
+
+    if (cbRead > 0)
+    {
+        cbTotalRead += cbRead;
 
-    successWrite = BlockChainStream_WriteAt(bbTempChain,
+        successWrite = BlockChainStream_WriteAt(bbTempChain,
                                             offset,
                                             cbRead,
                                             buffer,
                                             &cbWritten);
-    cbTotalWritten += cbWritten;
 
-    offset.u.LowPart += This->smallBlockSize;
+        if (!successWrite)
+            break;
 
-  } while (SUCCEEDED(successRead) && successWrite);
+        cbTotalWritten += cbWritten;
+        offset.u.LowPart += This->smallBlockSize;
+    }
+  } while (cbRead > 0);
   HeapFree(GetProcessHeap(),0,buffer);
 
   assert(cbTotalRead == cbTotalWritten);
-- 
1.0.6


More information about the wine-patches mailing list