Module: wine Branch: master Commit: b833ae026314306e2a18e975ff9d78444ef6d75e URL: http://source.winehq.org/git/wine.git/?a=commit;h=b833ae026314306e2a18e975ff...
Author: Hans Leidekker hans@codeweavers.com Date: Thu Feb 4 10:01:09 2010 +0100
msi: Improve error handling in STREAMS_set_row and add_streams_to_table.
---
dlls/msi/streams.c | 32 ++++++++++++++++++++++++++------ 1 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/dlls/msi/streams.c b/dlls/msi/streams.c index f7e8dc2..00a4544 100644 --- a/dlls/msi/streams.c +++ b/dlls/msi/streams.c @@ -141,7 +141,7 @@ static UINT STREAMS_set_row(struct tagMSIVIEW *view, UINT row, MSIRECORD *rec, U ULONG count; UINT r = ERROR_FUNCTION_FAILED;
- TRACE("(%p, %p)\n", view, rec); + TRACE("(%p, %d, %p, %08x)\n", view, row, rec, mask);
if (row > sv->num_rows) return ERROR_FUNCTION_FAILED; @@ -158,7 +158,10 @@ static UINT STREAMS_set_row(struct tagMSIVIEW *view, UINT row, MSIRECORD *rec, U }
if (stat.cbSize.QuadPart >> 32) + { + WARN("stream too large\n"); goto done; + }
data = msi_alloc(stat.cbSize.QuadPart); if (!data) @@ -173,7 +176,10 @@ static UINT STREAMS_set_row(struct tagMSIVIEW *view, UINT row, MSIRECORD *rec, U
name = strdupW(MSI_RecordGetString(rec, 1)); if (!name) + { + WARN("failed to retrieve stream name\n"); goto done; + }
r = write_stream_data(sv->db->storage, name, data, count, FALSE); if (r != ERROR_SUCCESS) @@ -186,8 +192,13 @@ static UINT STREAMS_set_row(struct tagMSIVIEW *view, UINT row, MSIRECORD *rec, U if (!stream) goto done;
- IStorage_OpenStream(sv->db->storage, name, 0, - STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &stream->stream); + hr = IStorage_OpenStream(sv->db->storage, name, 0, + STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &stream->stream); + if (FAILED(hr)) + { + WARN("failed to open stream: %08x\n", hr); + goto done; + }
sv->streams[row] = stream;
@@ -204,6 +215,8 @@ static UINT STREAMS_insert_row(struct tagMSIVIEW *view, MSIRECORD *rec, UINT row { MSISTREAMSVIEW *sv = (MSISTREAMSVIEW *)view;
+ TRACE("(%p, %p, %d, %d)\n", view, rec, row, temporary); + if (!streams_set_table_size(sv, ++sv->num_rows)) return ERROR_FUNCTION_FAILED;
@@ -411,7 +424,7 @@ static UINT STREAMS_find_matching_rows(struct tagMSIVIEW *view, UINT col, MSISTREAMSVIEW *sv = (MSISTREAMSVIEW *)view; UINT index = PtrToUlong(*handle);
- TRACE("(%d, %d): %d\n", *row, col, val); + TRACE("(%p, %d, %d, %p, %p)\n", view, col, val, row, handle);
if (col == 0 || col > NUM_STREAMS_COLS) return ERROR_INVALID_PARAMETER; @@ -499,10 +512,17 @@ static INT add_streams_to_table(MSISTREAMSVIEW *sv) break; }
- IStorage_OpenStream(sv->db->storage, stat.pwcsName, 0, - STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &stream->stream); + hr = IStorage_OpenStream(sv->db->storage, stat.pwcsName, 0, + STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &stream->stream); CoTaskMemFree(stat.pwcsName);
+ if (FAILED(hr)) + { + WARN("failed to open stream: %08x\n", hr); + count = -1; + break; + } + if (!streams_set_table_size(sv, ++count)) { count = -1;