ole32/tests: Guard ReleaseStgMedium with SUCCEEDED.
This commit is contained in:
parent
2e8de49ee1
commit
08df19b405
|
@ -477,8 +477,6 @@ static void test_get_clipboard(void)
|
||||||
hr = IDataObject_QueryGetData(data_obj, &fmtetc);
|
hr = IDataObject_QueryGetData(data_obj, &fmtetc);
|
||||||
ok(hr == DV_E_FORMATETC || broken(hr == S_OK),
|
ok(hr == DV_E_FORMATETC || broken(hr == S_OK),
|
||||||
"IDataObject_QueryGetData should have failed with DV_E_FORMATETC instead of 0x%08x\n", hr);
|
"IDataObject_QueryGetData should have failed with DV_E_FORMATETC instead of 0x%08x\n", hr);
|
||||||
if (hr == S_OK)
|
|
||||||
ReleaseStgMedium(&stgmedium);
|
|
||||||
|
|
||||||
InitFormatEtc(fmtetc, CF_TEXT, TYMED_HGLOBAL);
|
InitFormatEtc(fmtetc, CF_TEXT, TYMED_HGLOBAL);
|
||||||
fmtetc.cfFormat = CF_RIFF;
|
fmtetc.cfFormat = CF_RIFF;
|
||||||
|
@ -499,19 +497,19 @@ static void test_get_clipboard(void)
|
||||||
InitFormatEtc(fmtetc, CF_TEXT, TYMED_HGLOBAL);
|
InitFormatEtc(fmtetc, CF_TEXT, TYMED_HGLOBAL);
|
||||||
hr = IDataObject_GetData(data_obj, &fmtetc, &stgmedium);
|
hr = IDataObject_GetData(data_obj, &fmtetc, &stgmedium);
|
||||||
ok(hr == S_OK, "IDataObject_GetData failed with error 0x%08x\n", hr);
|
ok(hr == S_OK, "IDataObject_GetData failed with error 0x%08x\n", hr);
|
||||||
ReleaseStgMedium(&stgmedium);
|
if(SUCCEEDED(hr)) ReleaseStgMedium(&stgmedium);
|
||||||
|
|
||||||
InitFormatEtc(fmtetc, CF_TEXT, TYMED_HGLOBAL);
|
InitFormatEtc(fmtetc, CF_TEXT, TYMED_HGLOBAL);
|
||||||
fmtetc.dwAspect = 0xdeadbeef;
|
fmtetc.dwAspect = 0xdeadbeef;
|
||||||
hr = IDataObject_GetData(data_obj, &fmtetc, &stgmedium);
|
hr = IDataObject_GetData(data_obj, &fmtetc, &stgmedium);
|
||||||
ok(hr == S_OK, "IDataObject_GetData failed with error 0x%08x\n", hr);
|
ok(hr == S_OK, "IDataObject_GetData failed with error 0x%08x\n", hr);
|
||||||
ReleaseStgMedium(&stgmedium);
|
if(SUCCEEDED(hr)) ReleaseStgMedium(&stgmedium);
|
||||||
|
|
||||||
InitFormatEtc(fmtetc, CF_TEXT, TYMED_HGLOBAL);
|
InitFormatEtc(fmtetc, CF_TEXT, TYMED_HGLOBAL);
|
||||||
fmtetc.dwAspect = DVASPECT_THUMBNAIL;
|
fmtetc.dwAspect = DVASPECT_THUMBNAIL;
|
||||||
hr = IDataObject_GetData(data_obj, &fmtetc, &stgmedium);
|
hr = IDataObject_GetData(data_obj, &fmtetc, &stgmedium);
|
||||||
ok(hr == S_OK, "IDataObject_GetData failed with error 0x%08x\n", hr);
|
ok(hr == S_OK, "IDataObject_GetData failed with error 0x%08x\n", hr);
|
||||||
ReleaseStgMedium(&stgmedium);
|
if(SUCCEEDED(hr)) ReleaseStgMedium(&stgmedium);
|
||||||
|
|
||||||
InitFormatEtc(fmtetc, CF_TEXT, TYMED_HGLOBAL);
|
InitFormatEtc(fmtetc, CF_TEXT, TYMED_HGLOBAL);
|
||||||
fmtetc.lindex = 256;
|
fmtetc.lindex = 256;
|
||||||
|
@ -528,11 +526,13 @@ static void test_get_clipboard(void)
|
||||||
fmtetc.cfFormat = CF_RIFF;
|
fmtetc.cfFormat = CF_RIFF;
|
||||||
hr = IDataObject_GetData(data_obj, &fmtetc, &stgmedium);
|
hr = IDataObject_GetData(data_obj, &fmtetc, &stgmedium);
|
||||||
ok(hr == DV_E_FORMATETC, "IDataObject_GetData should have failed with DV_E_FORMATETC instead of 0x%08x\n", hr);
|
ok(hr == DV_E_FORMATETC, "IDataObject_GetData should have failed with DV_E_FORMATETC instead of 0x%08x\n", hr);
|
||||||
|
if(SUCCEEDED(hr)) ReleaseStgMedium(&stgmedium);
|
||||||
|
|
||||||
InitFormatEtc(fmtetc, CF_TEXT, TYMED_HGLOBAL);
|
InitFormatEtc(fmtetc, CF_TEXT, TYMED_HGLOBAL);
|
||||||
fmtetc.tymed = TYMED_FILE;
|
fmtetc.tymed = TYMED_FILE;
|
||||||
hr = IDataObject_GetData(data_obj, &fmtetc, &stgmedium);
|
hr = IDataObject_GetData(data_obj, &fmtetc, &stgmedium);
|
||||||
ok(hr == DV_E_TYMED, "IDataObject_GetData should have failed with DV_E_TYMED instead of 0x%08x\n", hr);
|
ok(hr == DV_E_TYMED, "IDataObject_GetData should have failed with DV_E_TYMED instead of 0x%08x\n", hr);
|
||||||
|
if(SUCCEEDED(hr)) ReleaseStgMedium(&stgmedium);
|
||||||
|
|
||||||
ok(DataObjectImpl_GetData_calls == 6, "DataObjectImpl_GetData should have been called 6 times instead of %d times\n", DataObjectImpl_GetData_calls);
|
ok(DataObjectImpl_GetData_calls == 6, "DataObjectImpl_GetData should have been called 6 times instead of %d times\n", DataObjectImpl_GetData_calls);
|
||||||
|
|
||||||
|
@ -967,7 +967,7 @@ static void test_consumer_refs(void)
|
||||||
hr = IDataObject_GetData(get1, &fmt, &med);
|
hr = IDataObject_GetData(get1, &fmt, &med);
|
||||||
ok(hr == S_OK, "got %08x\n", hr);
|
ok(hr == S_OK, "got %08x\n", hr);
|
||||||
ok(DataObjectImpl_GetData_calls == 0, "GetData called\n");
|
ok(DataObjectImpl_GetData_calls == 0, "GetData called\n");
|
||||||
ReleaseStgMedium(&med);
|
if(SUCCEEDED(hr)) ReleaseStgMedium(&med);
|
||||||
|
|
||||||
hr = OleGetClipboard(&get2);
|
hr = OleGetClipboard(&get2);
|
||||||
ok(hr == S_OK, "got %08x\n", hr);
|
ok(hr == S_OK, "got %08x\n", hr);
|
||||||
|
@ -1004,7 +1004,7 @@ static void test_consumer_refs(void)
|
||||||
hr = IDataObject_GetData(get1, &fmt, &med);
|
hr = IDataObject_GetData(get1, &fmt, &med);
|
||||||
ok(hr == S_OK, "got %08x\n", hr);
|
ok(hr == S_OK, "got %08x\n", hr);
|
||||||
ok(DataObjectImpl_GetData_calls == 1, "GetData not called\n");
|
ok(DataObjectImpl_GetData_calls == 1, "GetData not called\n");
|
||||||
ReleaseStgMedium(&med);
|
if(SUCCEEDED(hr)) ReleaseStgMedium(&med);
|
||||||
refs = count_refs(src);
|
refs = count_refs(src);
|
||||||
ok(refs == old_refs + 1, "%d %d\n", refs, old_refs);
|
ok(refs == old_refs + 1, "%d %d\n", refs, old_refs);
|
||||||
|
|
||||||
|
@ -1014,7 +1014,7 @@ static void test_consumer_refs(void)
|
||||||
hr = IDataObject_GetData(get1, &fmt, &med);
|
hr = IDataObject_GetData(get1, &fmt, &med);
|
||||||
ok(hr == S_OK, "got %08x\n", hr);
|
ok(hr == S_OK, "got %08x\n", hr);
|
||||||
ok(DataObjectImpl_GetData_calls == 1, "GetData not called\n");
|
ok(DataObjectImpl_GetData_calls == 1, "GetData not called\n");
|
||||||
ReleaseStgMedium(&med);
|
if(SUCCEEDED(hr)) ReleaseStgMedium(&med);
|
||||||
|
|
||||||
refs = count_refs(src);
|
refs = count_refs(src);
|
||||||
ok(refs == 2, "%d\n", refs);
|
ok(refs == 2, "%d\n", refs);
|
||||||
|
@ -1047,7 +1047,7 @@ static void test_consumer_refs(void)
|
||||||
hr = IDataObject_GetData(get1, &fmt, &med);
|
hr = IDataObject_GetData(get1, &fmt, &med);
|
||||||
ok(hr == S_OK, "got %08x\n", hr);
|
ok(hr == S_OK, "got %08x\n", hr);
|
||||||
ok(DataObjectImpl_GetData_calls == 1, "GetData not called\n");
|
ok(DataObjectImpl_GetData_calls == 1, "GetData not called\n");
|
||||||
ReleaseStgMedium(&med);
|
if(SUCCEEDED(hr)) ReleaseStgMedium(&med);
|
||||||
|
|
||||||
refs = count_refs(src);
|
refs = count_refs(src);
|
||||||
ok(refs == 1, "%d\n", refs);
|
ok(refs == 1, "%d\n", refs);
|
||||||
|
@ -1096,23 +1096,24 @@ static void test_flushed_getdata(void)
|
||||||
hr = IDataObject_GetData(get, &fmt, &med);
|
hr = IDataObject_GetData(get, &fmt, &med);
|
||||||
ok(hr == S_OK, "got %08x\n", hr);
|
ok(hr == S_OK, "got %08x\n", hr);
|
||||||
ok(med.tymed == TYMED_HGLOBAL, "got %x\n", med.tymed);
|
ok(med.tymed == TYMED_HGLOBAL, "got %x\n", med.tymed);
|
||||||
ReleaseStgMedium(&med);
|
if(SUCCEEDED(hr)) ReleaseStgMedium(&med);
|
||||||
|
|
||||||
InitFormatEtc(fmt, CF_TEXT, TYMED_ISTREAM);
|
InitFormatEtc(fmt, CF_TEXT, TYMED_ISTREAM);
|
||||||
hr = IDataObject_GetData(get, &fmt, &med);
|
hr = IDataObject_GetData(get, &fmt, &med);
|
||||||
ok(hr == S_OK, "got %08x\n", hr);
|
ok(hr == S_OK, "got %08x\n", hr);
|
||||||
ok(med.tymed == TYMED_ISTREAM, "got %x\n", med.tymed);
|
ok(med.tymed == TYMED_ISTREAM, "got %x\n", med.tymed);
|
||||||
ReleaseStgMedium(&med);
|
if(SUCCEEDED(hr)) ReleaseStgMedium(&med);
|
||||||
|
|
||||||
InitFormatEtc(fmt, CF_TEXT, TYMED_ISTORAGE);
|
InitFormatEtc(fmt, CF_TEXT, TYMED_ISTORAGE);
|
||||||
hr = IDataObject_GetData(get, &fmt, &med);
|
hr = IDataObject_GetData(get, &fmt, &med);
|
||||||
ok(hr == E_FAIL, "got %08x\n", hr);
|
ok(hr == E_FAIL, "got %08x\n", hr);
|
||||||
|
if(SUCCEEDED(hr)) ReleaseStgMedium(&med);
|
||||||
|
|
||||||
InitFormatEtc(fmt, CF_TEXT, 0xffff);
|
InitFormatEtc(fmt, CF_TEXT, 0xffff);
|
||||||
hr = IDataObject_GetData(get, &fmt, &med);
|
hr = IDataObject_GetData(get, &fmt, &med);
|
||||||
ok(hr == S_OK, "got %08x\n", hr);
|
ok(hr == S_OK, "got %08x\n", hr);
|
||||||
ok(med.tymed == TYMED_HGLOBAL, "got %x\n", med.tymed);
|
ok(med.tymed == TYMED_HGLOBAL, "got %x\n", med.tymed);
|
||||||
ReleaseStgMedium(&med);
|
if(SUCCEEDED(hr)) ReleaseStgMedium(&med);
|
||||||
|
|
||||||
/* stream format -> global & stream */
|
/* stream format -> global & stream */
|
||||||
|
|
||||||
|
@ -1120,23 +1121,24 @@ static void test_flushed_getdata(void)
|
||||||
hr = IDataObject_GetData(get, &fmt, &med);
|
hr = IDataObject_GetData(get, &fmt, &med);
|
||||||
ok(hr == S_OK, "got %08x\n", hr);
|
ok(hr == S_OK, "got %08x\n", hr);
|
||||||
ok(med.tymed == TYMED_ISTREAM, "got %x\n", med.tymed);
|
ok(med.tymed == TYMED_ISTREAM, "got %x\n", med.tymed);
|
||||||
ReleaseStgMedium(&med);
|
if(SUCCEEDED(hr)) ReleaseStgMedium(&med);
|
||||||
|
|
||||||
InitFormatEtc(fmt, cf_stream, TYMED_ISTORAGE);
|
InitFormatEtc(fmt, cf_stream, TYMED_ISTORAGE);
|
||||||
hr = IDataObject_GetData(get, &fmt, &med);
|
hr = IDataObject_GetData(get, &fmt, &med);
|
||||||
ok(hr == E_FAIL, "got %08x\n", hr);
|
ok(hr == E_FAIL, "got %08x\n", hr);
|
||||||
|
if(SUCCEEDED(hr)) ReleaseStgMedium(&med);
|
||||||
|
|
||||||
InitFormatEtc(fmt, cf_stream, TYMED_HGLOBAL);
|
InitFormatEtc(fmt, cf_stream, TYMED_HGLOBAL);
|
||||||
hr = IDataObject_GetData(get, &fmt, &med);
|
hr = IDataObject_GetData(get, &fmt, &med);
|
||||||
ok(hr == S_OK, "got %08x\n", hr);
|
ok(hr == S_OK, "got %08x\n", hr);
|
||||||
ok(med.tymed == TYMED_HGLOBAL, "got %x\n", med.tymed);
|
ok(med.tymed == TYMED_HGLOBAL, "got %x\n", med.tymed);
|
||||||
ReleaseStgMedium(&med);
|
if(SUCCEEDED(hr)) ReleaseStgMedium(&med);
|
||||||
|
|
||||||
InitFormatEtc(fmt, cf_stream, 0xffff);
|
InitFormatEtc(fmt, cf_stream, 0xffff);
|
||||||
hr = IDataObject_GetData(get, &fmt, &med);
|
hr = IDataObject_GetData(get, &fmt, &med);
|
||||||
ok(hr == S_OK, "got %08x\n", hr);
|
ok(hr == S_OK, "got %08x\n", hr);
|
||||||
ok(med.tymed == TYMED_ISTREAM, "got %x\n", med.tymed);
|
ok(med.tymed == TYMED_ISTREAM, "got %x\n", med.tymed);
|
||||||
ReleaseStgMedium(&med);
|
if(SUCCEEDED(hr)) ReleaseStgMedium(&med);
|
||||||
|
|
||||||
/* storage format -> global, stream & storage */
|
/* storage format -> global, stream & storage */
|
||||||
|
|
||||||
|
@ -1144,34 +1146,36 @@ static void test_flushed_getdata(void)
|
||||||
hr = IDataObject_GetData(get, &fmt, &med);
|
hr = IDataObject_GetData(get, &fmt, &med);
|
||||||
ok(hr == S_OK, "got %08x\n", hr);
|
ok(hr == S_OK, "got %08x\n", hr);
|
||||||
ok(med.tymed == TYMED_ISTORAGE, "got %x\n", med.tymed);
|
ok(med.tymed == TYMED_ISTORAGE, "got %x\n", med.tymed);
|
||||||
|
if(SUCCEEDED(hr)) {
|
||||||
hr = IStorage_Stat(med.u.pstg, &stat, STATFLAG_NONAME);
|
hr = IStorage_Stat(med.u.pstg, &stat, STATFLAG_NONAME);
|
||||||
ok(hr == S_OK, "got %08x\n", hr);
|
ok(hr == S_OK, "got %08x\n", hr);
|
||||||
ok(stat.grfMode == (STGM_SHARE_EXCLUSIVE | STGM_READWRITE), "got %08x\n", stat.grfMode);
|
ok(stat.grfMode == (STGM_SHARE_EXCLUSIVE | STGM_READWRITE), "got %08x\n", stat.grfMode);
|
||||||
ReleaseStgMedium(&med);
|
ReleaseStgMedium(&med);
|
||||||
|
}
|
||||||
|
|
||||||
InitFormatEtc(fmt, cf_storage, TYMED_ISTREAM);
|
InitFormatEtc(fmt, cf_storage, TYMED_ISTREAM);
|
||||||
hr = IDataObject_GetData(get, &fmt, &med);
|
hr = IDataObject_GetData(get, &fmt, &med);
|
||||||
ok(hr == S_OK, "got %08x\n", hr);
|
ok(hr == S_OK, "got %08x\n", hr);
|
||||||
ok(med.tymed == TYMED_ISTREAM, "got %x\n", med.tymed);
|
ok(med.tymed == TYMED_ISTREAM, "got %x\n", med.tymed);
|
||||||
ReleaseStgMedium(&med);
|
if(SUCCEEDED(hr)) ReleaseStgMedium(&med);
|
||||||
|
|
||||||
InitFormatEtc(fmt, cf_storage, TYMED_HGLOBAL);
|
InitFormatEtc(fmt, cf_storage, TYMED_HGLOBAL);
|
||||||
hr = IDataObject_GetData(get, &fmt, &med);
|
hr = IDataObject_GetData(get, &fmt, &med);
|
||||||
ok(hr == S_OK, "got %08x\n", hr);
|
ok(hr == S_OK, "got %08x\n", hr);
|
||||||
ok(med.tymed == TYMED_HGLOBAL, "got %x\n", med.tymed);
|
ok(med.tymed == TYMED_HGLOBAL, "got %x\n", med.tymed);
|
||||||
ReleaseStgMedium(&med);
|
if(SUCCEEDED(hr)) ReleaseStgMedium(&med);
|
||||||
|
|
||||||
InitFormatEtc(fmt, cf_storage, TYMED_HGLOBAL | TYMED_ISTREAM);
|
InitFormatEtc(fmt, cf_storage, TYMED_HGLOBAL | TYMED_ISTREAM);
|
||||||
hr = IDataObject_GetData(get, &fmt, &med);
|
hr = IDataObject_GetData(get, &fmt, &med);
|
||||||
ok(hr == S_OK, "got %08x\n", hr);
|
ok(hr == S_OK, "got %08x\n", hr);
|
||||||
ok(med.tymed == TYMED_HGLOBAL, "got %x\n", med.tymed);
|
ok(med.tymed == TYMED_HGLOBAL, "got %x\n", med.tymed);
|
||||||
ReleaseStgMedium(&med);
|
if(SUCCEEDED(hr)) ReleaseStgMedium(&med);
|
||||||
|
|
||||||
InitFormatEtc(fmt, cf_storage, 0xffff);
|
InitFormatEtc(fmt, cf_storage, 0xffff);
|
||||||
hr = IDataObject_GetData(get, &fmt, &med);
|
hr = IDataObject_GetData(get, &fmt, &med);
|
||||||
ok(hr == S_OK, "got %08x\n", hr);
|
ok(hr == S_OK, "got %08x\n", hr);
|
||||||
ok(med.tymed == TYMED_ISTORAGE, "got %x\n", med.tymed);
|
ok(med.tymed == TYMED_ISTORAGE, "got %x\n", med.tymed);
|
||||||
ReleaseStgMedium(&med);
|
if(SUCCEEDED(hr)) ReleaseStgMedium(&med);
|
||||||
|
|
||||||
/* complex format with target device */
|
/* complex format with target device */
|
||||||
|
|
||||||
|
@ -1180,7 +1184,7 @@ static void test_flushed_getdata(void)
|
||||||
ok(hr == DV_E_FORMATETC ||
|
ok(hr == DV_E_FORMATETC ||
|
||||||
broken(hr == S_OK), /* win9x, winme & nt4 */
|
broken(hr == S_OK), /* win9x, winme & nt4 */
|
||||||
"got %08x\n", hr);
|
"got %08x\n", hr);
|
||||||
if(hr == S_OK) ReleaseStgMedium(&med);
|
if(SUCCEEDED(hr)) ReleaseStgMedium(&med);
|
||||||
|
|
||||||
InitFormatEtc(fmt, cf_another, 0xffff);
|
InitFormatEtc(fmt, cf_another, 0xffff);
|
||||||
memset(&dm, 0, sizeof(dm));
|
memset(&dm, 0, sizeof(dm));
|
||||||
|
@ -1199,7 +1203,7 @@ static void test_flushed_getdata(void)
|
||||||
hr = IDataObject_GetData(get, &fmt, &med);
|
hr = IDataObject_GetData(get, &fmt, &med);
|
||||||
ok(hr == S_OK, "got %08x\n", hr);
|
ok(hr == S_OK, "got %08x\n", hr);
|
||||||
ok(med.tymed == TYMED_ISTORAGE, "got %x\n", med.tymed);
|
ok(med.tymed == TYMED_ISTORAGE, "got %x\n", med.tymed);
|
||||||
ReleaseStgMedium(&med);
|
if(SUCCEEDED(hr)) ReleaseStgMedium(&med);
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(), 0, fmt.ptd);
|
HeapFree(GetProcessHeap(), 0, fmt.ptd);
|
||||||
|
|
||||||
|
@ -1356,7 +1360,7 @@ static void test_nonole_clipboard(void)
|
||||||
ok(hr == S_OK, "got %08x\n", hr);
|
ok(hr == S_OK, "got %08x\n", hr);
|
||||||
obj_type = GetObjectType(U(med).hEnhMetaFile);
|
obj_type = GetObjectType(U(med).hEnhMetaFile);
|
||||||
ok(obj_type == OBJ_ENHMETAFILE, "got %d\n", obj_type);
|
ok(obj_type == OBJ_ENHMETAFILE, "got %d\n", obj_type);
|
||||||
ReleaseStgMedium(&med);
|
if(SUCCEEDED(hr)) ReleaseStgMedium(&med);
|
||||||
|
|
||||||
IDataObject_Release(get);
|
IDataObject_Release(get);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue