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.
This commit is contained in:
Vincent Povirk 2010-05-12 14:08:55 -05:00 committed by Alexandre Julliard
parent f10af18f28
commit 57ddceea34
1 changed files with 14 additions and 13 deletions

View File

@ -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;