[PATCH] ole32: Prevent adding additional cache entries to static class caches.
Sergio Gómez Del Real
sdelreal at codeweavers.com
Mon Jan 22 08:35:01 CST 2018
Signed-off-by: Sergio Gómez Del Real <sdelreal at codeweavers.com>
---
dlls/ole32/datacache.c | 4 ++++
dlls/ole32/tests/ole2.c | 23 +++++++++++++++++++++++
2 files changed, 27 insertions(+)
diff --git a/dlls/ole32/datacache.c b/dlls/ole32/datacache.c
index 4ba08268d7..fa0c857f15 100644
--- a/dlls/ole32/datacache.c
+++ b/dlls/ole32/datacache.c
@@ -2440,6 +2440,10 @@ static HRESULT WINAPI DataCache_Cache(
*pdwConnection = cache_entry->id;
return CACHE_S_SAMECACHE;
}
+ if (IsEqualCLSID(&This->clsid, &CLSID_Picture_Dib) ||
+ IsEqualCLSID(&This->clsid, &CLSID_Picture_Metafile) ||
+ IsEqualCLSID(&This->clsid, &CLSID_Picture_EnhMetafile))
+ return DV_E_FORMATETC;
hr = DataCache_CreateEntry(This, &fmt_cpy, advf, FALSE, &cache_entry);
diff --git a/dlls/ole32/tests/ole2.c b/dlls/ole32/tests/ole2.c
index fe45c6a73e..a9f68f15ba 100644
--- a/dlls/ole32/tests/ole2.c
+++ b/dlls/ole32/tests/ole2.c
@@ -2426,6 +2426,29 @@ static void test_data_cache_cache(void)
IDataObject_Release( data );
IOleCache2_Release( cache );
+
+ /* tests for a static class cache */
+ hr = CreateDataCache( NULL, &CLSID_Picture_Dib, &IID_IOleCache2, (void **)&cache );
+
+ fmt.cfFormat = CF_DIB;
+ fmt.dwAspect = DVASPECT_CONTENT;
+ fmt.tymed = TYMED_HGLOBAL;
+ hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
+ ok( hr == CACHE_S_SAMECACHE, "got %08x\n", hr );
+
+ /* aspect other than DVASPECT_CONTENT should fail */
+ fmt.dwAspect = DVASPECT_THUMBNAIL;
+ hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
+ ok( FAILED(hr), "got %08x\n", hr );
+
+ /* try caching another clip format */
+ fmt.dwAspect = DVASPECT_CONTENT;
+ fmt.cfFormat = CF_METAFILEPICT;
+ fmt.tymed = TYMED_MFPICT;
+ hr = IOleCache2_Cache( cache, &fmt, 0, &conn );
+ ok( FAILED(hr), "got %08x\n", hr );
+
+ IOleCache2_Release( cache );
}
/* The CLSID_Picture_ classes automatically create appropriate cache entries */
--
2.14.1
More information about the wine-devel
mailing list