Commit fa23c7fc authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

msi: Handle errors from IStorage_CreateStream instead of trying to open the…

msi: Handle errors from IStorage_CreateStream instead of trying to open the stream first in msi_commit_streams.
parent db3fdbe1
......@@ -613,30 +613,29 @@ UINT msi_commit_streams( MSIDATABASE *db )
name = msi_string_lookup( db->strings, db->streams[i].str_index, NULL );
if (!(encname = encode_streamname( FALSE, name ))) return ERROR_OUTOFMEMORY;
hr = open_stream( db, encname, &stream );
if (FAILED( hr )) /* new stream */
hr = IStorage_CreateStream( db->storage, encname, STGM_WRITE|STGM_SHARE_EXCLUSIVE, 0, 0, &stream );
if (SUCCEEDED( hr ))
{
hr = IStorage_CreateStream( db->storage, encname, STGM_WRITE|STGM_SHARE_EXCLUSIVE, 0, 0, &stream );
hr = write_stream( stream, db->streams[i].stream );
if (FAILED( hr ))
{
ERR("failed to create stream %s (hr = %08x)\n", debugstr_w(encname), hr);
ERR("failed to write stream %s (hr = %08x)\n", debugstr_w(encname), hr);
msi_free( encname );
IStream_Release( stream );
return ERROR_FUNCTION_FAILED;
}
hr = write_stream( stream, db->streams[i].stream );
hr = IStream_Commit( stream, 0 );
IStream_Release( stream );
if (FAILED( hr ))
{
ERR("failed to write stream %s (hr = %08x)\n", debugstr_w(encname), hr);
ERR("failed to commit stream %s (hr = %08x)\n", debugstr_w(encname), hr);
msi_free( encname );
IStream_Release( stream );
return ERROR_FUNCTION_FAILED;
}
}
hr = IStream_Commit( stream, 0 );
IStream_Release( stream );
if (FAILED( hr ))
else if (hr != STG_E_FILEALREADYEXISTS)
{
WARN("failed to commit stream %s (hr = %08x)\n", debugstr_w(encname), hr);
ERR("failed to create stream %s (hr = %08x)\n", debugstr_w(encname), hr);
msi_free( encname );
return ERROR_FUNCTION_FAILED;
}
......
......@@ -3189,7 +3189,8 @@ static void test_try_transform(void)
r = MsiDatabaseApplyTransformA( hdb, mstfile, 0 );
ok( r == ERROR_SUCCESS, "return code %d, should be ERROR_SUCCESS\n", r );
MsiDatabaseCommit( hdb );
r = MsiDatabaseCommit( hdb );
ok( r == ERROR_SUCCESS , "Failed to commit database\n" );
/* check new values */
hrec = 0;
......
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