Module: wine Branch: master Commit: fa23c7fcb33a8c01189316c3b0a3600b078bd145 URL: http://source.winehq.org/git/wine.git/?a=commit;h=fa23c7fcb33a8c01189316c3b0...
Author: Hans Leidekker hans@codeweavers.com Date: Mon Mar 16 10:56:35 2015 +0100
msi: Handle errors from IStorage_CreateStream instead of trying to open the stream first in msi_commit_streams.
---
dlls/msi/streams.c | 21 ++++++++++----------- dlls/msi/tests/db.c | 3 ++- 2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/dlls/msi/streams.c b/dlls/msi/streams.c index 4b151bb..7f9582c 100644 --- a/dlls/msi/streams.c +++ b/dlls/msi/streams.c @@ -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; } diff --git a/dlls/msi/tests/db.c b/dlls/msi/tests/db.c index 3d8568d..d629e1c 100644 --- a/dlls/msi/tests/db.c +++ b/dlls/msi/tests/db.c @@ -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;