Robert Shearman : ole32: Remove some assertions in the stuctured storage code by

Alexandre Julliard julliard at wine.codeweavers.com
Mon Sep 11 06:05:13 CDT 2006


Module: wine
Branch: master
Commit: 106156cb7597cf6f077b6f4e9d7562d8932fd766
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=106156cb7597cf6f077b6f4e9d7562d8932fd766

Author: Robert Shearman <rob at codeweavers.com>
Date:   Mon Sep 11 11:14:25 2006 +0100

ole32: Remove some assertions in the stuctured storage code by
returning error codes to the caller and by handling the error
condition.

---

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

diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c
index 3860431..19f09fc 100644
--- a/dlls/ole32/storage32.c
+++ b/dlls/ole32/storage32.c
@@ -3557,7 +3557,7 @@ BlockChainStream* Storage32Impl_SmallBlo
   ULARGE_INTEGER size, offset;
   ULONG cbRead, cbWritten, cbTotalRead, cbTotalWritten;
   ULONG propertyIndex;
-  HRESULT resWrite;
+  HRESULT resWrite = S_OK;
   HRESULT resRead;
   StgProperty chainProperty;
   BYTE *buffer;
@@ -3593,7 +3593,7 @@ BlockChainStream* Storage32Impl_SmallBlo
   {
     resRead = SmallBlockChainStream_ReadAt(*ppsbChain,
                                            offset,
-                                           DEF_SMALL_BLOCK_SIZE,
+                                           This->smallBlockSize,
                                            buffer,
                                            &cbRead);
     if (FAILED(resRead))
@@ -3618,7 +3618,12 @@ BlockChainStream* Storage32Impl_SmallBlo
   } while (cbRead > 0);
   HeapFree(GetProcessHeap(),0,buffer);
 
-  assert(cbTotalRead == cbTotalWritten);
+  if (FAILED(resRead) || FAILED(resWrite))
+  {
+    ERR("conversion failed: resRead = 0x%08lx, resWrite = 0x%08lx\n", resRead, resWrite);
+    BlockChainStream_Destroy(bbTempChain);
+    return NULL;
+  }
 
   /*
    * Destroy the small block chain.
@@ -5319,8 +5324,6 @@ HRESULT SmallBlockChainStream_ReadAt(
     if (FAILED(rc))
       return rc;
 
-    assert(bytesReadFromBigBlockFile == bytesToReadInBuffer);
-
     /*
      * Step to the next big block.
      */
@@ -5328,10 +5331,10 @@ HRESULT SmallBlockChainStream_ReadAt(
     if(FAILED(rc))
       return STG_E_DOCFILECORRUPT;
 
-    bufferWalker += bytesToReadInBuffer;
-    size         -= bytesToReadInBuffer;
-    *bytesRead   += bytesToReadInBuffer;
-    offsetInBlock = 0;  /* There is no offset on the next block */
+    bufferWalker += bytesReadFromBigBlockFile;
+    size         -= bytesReadFromBigBlockFile;
+    *bytesRead   += bytesReadFromBigBlockFile;
+    offsetInBlock = (offsetInBlock + bytesReadFromBigBlockFile) % This->parentStorage->smallBlockSize;
   }
 
   return (size == 0) ? S_OK : STG_E_READFAULT;
@@ -5358,7 +5361,7 @@ HRESULT SmallBlockChainStream_WriteAt(
   ULONG offsetInBlock = offset.u.LowPart % This->parentStorage->smallBlockSize;
   ULONG bytesToWriteInBuffer;
   ULONG blockIndex;
-  ULONG bytesWrittenFromBigBlockFile;
+  ULONG bytesWrittenToBigBlockFile;
   const BYTE* bufferWalker;
   HRESULT res;
 
@@ -5412,22 +5415,20 @@ HRESULT SmallBlockChainStream_WriteAt(
       offsetInBigBlockFile,
       bytesToWriteInBuffer,
       bufferWalker,
-      &bytesWrittenFromBigBlockFile);
+      &bytesWrittenToBigBlockFile);
     if (FAILED(res))
       return res;
 
-    assert(bytesWrittenFromBigBlockFile == bytesToWriteInBuffer);
-
     /*
      * Step to the next big block.
      */
     if(FAILED(SmallBlockChainStream_GetNextBlockInChain(This, blockIndex,
 							&blockIndex)))
       return FALSE;
-    bufferWalker  += bytesToWriteInBuffer;
-    size          -= bytesToWriteInBuffer;
-    *bytesWritten += bytesToWriteInBuffer;
-    offsetInBlock  = 0;     /* There is no offset on the next block */
+    bufferWalker  += bytesWrittenToBigBlockFile;
+    size          -= bytesWrittenToBigBlockFile;
+    *bytesWritten += bytesWrittenToBigBlockFile;
+    offsetInBlock  = (offsetInBlock + bytesWrittenToBigBlockFile) % This->parentStorage->smallBlockSize;
   }
 
   return (size == 0) ? S_OK : STG_E_WRITEFAULT;




More information about the wine-cvs mailing list