Commit 6937e3ce authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

ole32: Always initialize storage header before writing it.

parent 6fdbec08
...@@ -3016,20 +3016,10 @@ static void StorageImpl_SaveFileHeader( ...@@ -3016,20 +3016,10 @@ static void StorageImpl_SaveFileHeader(
{ {
BYTE headerBigBlock[HEADER_SIZE]; BYTE headerBigBlock[HEADER_SIZE];
int index; int index;
HRESULT hr;
ULARGE_INTEGER offset; ULARGE_INTEGER offset;
DWORD bytes_read, bytes_written; DWORD bytes_written;
DWORD major_version, dirsectorcount; DWORD major_version, dirsectorcount;
/*
* Get a pointer to the big block of data containing the header.
*/
offset.u.HighPart = 0;
offset.u.LowPart = 0;
hr = StorageImpl_ReadAt(This, offset, headerBigBlock, HEADER_SIZE, &bytes_read);
if (SUCCEEDED(hr) && bytes_read != HEADER_SIZE)
hr = STG_E_FILENOTFOUND;
if (This->bigBlockSizeBits == 0x9) if (This->bigBlockSizeBits == 0x9)
major_version = 3; major_version = 3;
else if (This->bigBlockSizeBits == 0xc) else if (This->bigBlockSizeBits == 0xc)
...@@ -3040,21 +3030,8 @@ static void StorageImpl_SaveFileHeader( ...@@ -3040,21 +3030,8 @@ static void StorageImpl_SaveFileHeader(
major_version = 4; major_version = 4;
} }
/* memset(headerBigBlock, 0, HEADER_SIZE);
* If the block read failed, the file is probably new. memcpy(headerBigBlock, STORAGE_magic, sizeof(STORAGE_magic));
*/
if (FAILED(hr))
{
/*
* Initialize for all unknown fields.
*/
memset(headerBigBlock, 0, HEADER_SIZE);
/*
* Initialize the magic number.
*/
memcpy(headerBigBlock, STORAGE_magic, sizeof(STORAGE_magic));
}
/* /*
* Write the information to the header. * Write the information to the header.
...@@ -3150,9 +3127,7 @@ static void StorageImpl_SaveFileHeader( ...@@ -3150,9 +3127,7 @@ static void StorageImpl_SaveFileHeader(
(This->bigBlockDepotStart[index])); (This->bigBlockDepotStart[index]));
} }
/* offset.QuadPart = 0;
* Write the big block back to the file.
*/
StorageImpl_WriteAt(This, offset, headerBigBlock, HEADER_SIZE, &bytes_written); StorageImpl_WriteAt(This, offset, headerBigBlock, HEADER_SIZE, &bytes_written);
} }
......
...@@ -3883,7 +3883,6 @@ static void test_custom_lockbytes(void) ...@@ -3883,7 +3883,6 @@ static void test_custom_lockbytes(void)
hr = IStorage_Commit(stg, 0); hr = IStorage_Commit(stg, 0);
ok(hr==S_OK, "IStorage_Commit failed %x\n", hr); ok(hr==S_OK, "IStorage_Commit failed %x\n", hr);
todo_wine
ok(*(DWORD *)lockbytes->contents == 0xe011cfd0, "contents: %08x\n", *(DWORD *)lockbytes->contents); ok(*(DWORD *)lockbytes->contents == 0xe011cfd0, "contents: %08x\n", *(DWORD *)lockbytes->contents);
IStorage_Release(stg); IStorage_Release(stg);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment