Vincent Povirk : ole32: Always check the size of the small block root chain .
Alexandre Julliard
julliard at winehq.org
Fri May 28 09:43:11 CDT 2010
Module: wine
Branch: master
Commit: 9c95761d9e3d9f38490efdb2f81c08b38c40c54c
URL: http://source.winehq.org/git/wine.git/?a=commit;h=9c95761d9e3d9f38490efdb2f81c08b38c40c54c
Author: Vincent Povirk <vincent at codeweavers.com>
Date: Thu May 27 17:16:22 2010 -0500
ole32: Always check the size of the small block root chain.
In some storage files, the size of this stream is not a multiple of the big
block size. This means that we may need to enlarge the stream even when we
don't really have to allocate more space for it.
---
dlls/ole32/storage32.c | 42 ++++++++++++++++++++----------------------
1 files changed, 20 insertions(+), 22 deletions(-)
diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c
index ce4e885..98df144 100644
--- a/dlls/ole32/storage32.c
+++ b/dlls/ole32/storage32.c
@@ -6390,6 +6390,9 @@ static ULONG SmallBlockChainStream_GetNextFreeBlock(
ULONG nextBlockIndex = BLOCK_END_OF_CHAIN;
HRESULT res = S_OK;
ULONG smallBlocksPerBigBlock;
+ DirEntry rootEntry;
+ ULONG blocksRequired;
+ ULARGE_INTEGER old_size, size_required;
offsetOfBlockInDepot.u.HighPart = 0;
@@ -6449,34 +6452,29 @@ static ULONG SmallBlockChainStream_GetNextFreeBlock(
/*
* Verify if we have to allocate big blocks to contain small blocks
*/
- if (blockIndex % smallBlocksPerBigBlock == 0)
- {
- DirEntry rootEntry;
- ULONG blocksRequired = (blockIndex / smallBlocksPerBigBlock) + 1;
- ULARGE_INTEGER old_size, size_required;
+ blocksRequired = (blockIndex / smallBlocksPerBigBlock) + 1;
- size_required.QuadPart = blocksRequired * This->parentStorage->bigBlockSize;
+ size_required.QuadPart = blocksRequired * This->parentStorage->bigBlockSize;
- old_size = BlockChainStream_GetSize(This->parentStorage->smallBlockRootChain);
+ old_size = BlockChainStream_GetSize(This->parentStorage->smallBlockRootChain);
- if (size_required.QuadPart > old_size.QuadPart)
- {
- BlockChainStream_SetSize(
- This->parentStorage->smallBlockRootChain,
- size_required);
+ if (size_required.QuadPart > old_size.QuadPart)
+ {
+ BlockChainStream_SetSize(
+ This->parentStorage->smallBlockRootChain,
+ size_required);
- StorageImpl_ReadDirEntry(
- This->parentStorage,
- This->parentStorage->base.storageDirEntry,
- &rootEntry);
+ StorageImpl_ReadDirEntry(
+ This->parentStorage,
+ This->parentStorage->base.storageDirEntry,
+ &rootEntry);
- rootEntry.size = size_required;
+ rootEntry.size = size_required;
- StorageImpl_WriteDirEntry(
- This->parentStorage,
- This->parentStorage->base.storageDirEntry,
- &rootEntry);
- }
+ StorageImpl_WriteDirEntry(
+ This->parentStorage,
+ This->parentStorage->base.storageDirEntry,
+ &rootEntry);
}
return blockIndex;
More information about the wine-cvs
mailing list