Rob Shearman : ole32:
Check that the specified clipboard format and tymed are valid in
IOleCache ::Cache in the data cache.
Alexandre Julliard
julliard at wine.codeweavers.com
Mon Dec 4 07:17:15 CST 2006
Module: wine
Branch: master
Commit: d37b669503ec73fde07f274f0ec97e69fd543d77
URL: http://source.winehq.org/git/wine.git/?a=commit;h=d37b669503ec73fde07f274f0ec97e69fd543d77
Author: Rob Shearman <rob at codeweavers.com>
Date: Sat Dec 2 18:16:47 2006 +0000
ole32: Check that the specified clipboard format and tymed are valid in IOleCache::Cache in the data cache.
---
dlls/ole32/datacache.c | 30 +++++++++++++++++++++++++++++-
1 files changed, 29 insertions(+), 1 deletions(-)
diff --git a/dlls/ole32/datacache.c b/dlls/ole32/datacache.c
index f5f43eb..d6d34d0 100644
--- a/dlls/ole32/datacache.c
+++ b/dlls/ole32/datacache.c
@@ -249,8 +249,36 @@ static DataCacheEntry *DataCache_GetEntr
return NULL;
}
+/* checks that the clipformat and tymed are valid and returns an error if they
+* aren't and CACHE_S_NOTSUPPORTED if they are valid, but can't be rendered by
+* DataCache_Draw */
+static HRESULT check_valid_clipformat_and_tymed(CLIPFORMAT cfFormat, DWORD tymed)
+{
+ if (!cfFormat || !tymed ||
+ (cfFormat == CF_METAFILEPICT && tymed == TYMED_MFPICT) ||
+ (cfFormat == CF_BITMAP && tymed == TYMED_GDI) ||
+ (cfFormat == CF_DIB && tymed == TYMED_HGLOBAL) ||
+ (cfFormat == CF_ENHMETAFILE && tymed == TYMED_ENHMF))
+ return S_OK;
+ else if (tymed == TYMED_HGLOBAL)
+ return CACHE_S_FORMATETC_NOTSUPPORTED;
+ else
+ {
+ WARN("invalid clipformat/tymed combination: %d/%d\n", cfFormat, tymed);
+ return DV_E_TYMED;
+ }
+}
+
static HRESULT DataCache_CreateEntry(DataCache *This, const FORMATETC *formatetc, DataCacheEntry **cache_entry)
{
+ HRESULT hr;
+
+ hr = check_valid_clipformat_and_tymed(formatetc->cfFormat, formatetc->tymed);
+ if (FAILED(hr))
+ return hr;
+ if (hr == CACHE_S_FORMATETC_NOTSUPPORTED)
+ TRACE("creating unsupported format %d\n", formatetc->cfFormat);
+
*cache_entry = HeapAlloc(GetProcessHeap(), 0, sizeof(**cache_entry));
if (!*cache_entry)
return E_OUTOFMEMORY;
@@ -268,7 +296,7 @@ static HRESULT DataCache_CreateEntry(Dat
(*cache_entry)->dirty = TRUE;
(*cache_entry)->stream_number = -1;
list_add_tail(&This->cache_list, &(*cache_entry)->entry);
- return S_OK;
+ return hr;
}
/************************************************************************
More information about the wine-cvs
mailing list