From fbcd70b002f6c0c6ea2d4f2b91e80ed7a274de61 Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Wed, 12 May 2010 14:08:55 -0500 Subject: [PATCH] ole32: Use a temporary variable in TransactedSnapshotImpl_EnsureReadEntry. CreateStubEntry can change the value of This->entries, in which case the assignment can go to the wrong place. So instead, assign to a temporary variable, and copy the data back after all CreateStubEntry calls are finished. --- dlls/ole32/storage32.c | 27 ++++++++++++++------------- 1 files changed, 14 insertions(+), 13 deletions(-) diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c index d136837..ce4e885 100644 --- a/dlls/ole32/storage32.c +++ b/dlls/ole32/storage32.c @@ -4160,42 +4160,43 @@ static HRESULT TransactedSnapshotImpl_EnsureReadEntry( TransactedSnapshotImpl *This, DirRef entry) { HRESULT hr=S_OK; + DirEntry data; if (!This->entries[entry].read) { hr = StorageBaseImpl_ReadDirEntry(This->transactedParent, This->entries[entry].transactedParentEntry, - &This->entries[entry].data); + &data); - if (SUCCEEDED(hr) && This->entries[entry].data.leftChild != DIRENTRY_NULL) + if (SUCCEEDED(hr) && data.leftChild != DIRENTRY_NULL) { - This->entries[entry].data.leftChild = - TransactedSnapshotImpl_CreateStubEntry(This, This->entries[entry].data.leftChild); + data.leftChild = TransactedSnapshotImpl_CreateStubEntry(This, data.leftChild); - if (This->entries[entry].data.leftChild == DIRENTRY_NULL) + if (data.leftChild == DIRENTRY_NULL) hr = E_OUTOFMEMORY; } - if (SUCCEEDED(hr) && This->entries[entry].data.rightChild != DIRENTRY_NULL) + if (SUCCEEDED(hr) && data.rightChild != DIRENTRY_NULL) { - This->entries[entry].data.rightChild = - TransactedSnapshotImpl_CreateStubEntry(This, This->entries[entry].data.rightChild); + data.rightChild = TransactedSnapshotImpl_CreateStubEntry(This, data.rightChild); - if (This->entries[entry].data.rightChild == DIRENTRY_NULL) + if (data.rightChild == DIRENTRY_NULL) hr = E_OUTOFMEMORY; } - if (SUCCEEDED(hr) && This->entries[entry].data.dirRootEntry != DIRENTRY_NULL) + if (SUCCEEDED(hr) && data.dirRootEntry != DIRENTRY_NULL) { - This->entries[entry].data.dirRootEntry = - TransactedSnapshotImpl_CreateStubEntry(This, This->entries[entry].data.dirRootEntry); + data.dirRootEntry = TransactedSnapshotImpl_CreateStubEntry(This, data.dirRootEntry); - if (This->entries[entry].data.dirRootEntry == DIRENTRY_NULL) + if (data.dirRootEntry == DIRENTRY_NULL) hr = E_OUTOFMEMORY; } if (SUCCEEDED(hr)) + { + memcpy(&This->entries[entry].data, &data, sizeof(DirEntry)); This->entries[entry].read = 1; + } } return hr; -- 1.6.3.3