Huw Davies : ole32: Check that the target devices match.

Alexandre Julliard julliard at winehq.org
Tue Apr 21 11:45:44 CDT 2009


Module: wine
Branch: master
Commit: 1e73a54690c7870075d950b98721c7ebe02f5adb
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=1e73a54690c7870075d950b98721c7ebe02f5adb

Author: Huw Davies <huw at codeweavers.com>
Date:   Thu Apr 16 16:49:35 2009 +0100

ole32: Check that the target devices match.

---

 dlls/ole32/clipboard.c       |   36 ++++++++++++++++++++++++++++++++++++
 dlls/ole32/tests/clipboard.c |    2 +-
 2 files changed, 37 insertions(+), 1 deletions(-)

diff --git a/dlls/ole32/clipboard.c b/dlls/ole32/clipboard.c
index 8aa14dc..9397a14 100644
--- a/dlls/ole32/clipboard.c
+++ b/dlls/ole32/clipboard.c
@@ -1063,6 +1063,36 @@ static HRESULT get_stgmed_for_storage(HGLOBAL h, STGMEDIUM *med)
     return hr;
 }
 
+static inline BOOL string_off_equal(const DVTARGETDEVICE *t1, WORD off1, const DVTARGETDEVICE *t2, WORD off2)
+{
+    const WCHAR *str1, *str2;
+
+    if(off1 == 0 && off2 == 0) return TRUE;
+    if(off1 == 0 || off2 == 0) return FALSE;
+
+    str1 = (const WCHAR*)((const char*)t1 + off1);
+    str2 = (const WCHAR*)((const char*)t2 + off2);
+
+    return !lstrcmpW(str1, str2);
+}
+
+static inline BOOL td_equal(const DVTARGETDEVICE *t1, const DVTARGETDEVICE *t2)
+{
+    if(t1 == NULL && t2 == NULL) return TRUE;
+    if(t1 == NULL || t2 == NULL) return FALSE;
+
+    if(!string_off_equal(t1, t1->tdDriverNameOffset, t2, t2->tdDriverNameOffset))
+        return FALSE;
+    if(!string_off_equal(t1, t1->tdDeviceNameOffset, t2, t2->tdDeviceNameOffset))
+        return FALSE;
+    if(!string_off_equal(t1, t1->tdPortNameOffset, t2, t2->tdPortNameOffset))
+        return FALSE;
+
+    /* FIXME check devmode? */
+
+    return TRUE;
+}
+
 /************************************************************************
  *         snapshot_GetData
  */
@@ -1105,6 +1135,11 @@ static HRESULT WINAPI snapshot_GetData(IDataObject *iface, FORMATETC *fmt,
     entry = find_format_in_list(enum_data->entries, enum_data->count, fmt->cfFormat);
     if(entry)
     {
+        if(!td_equal(fmt->ptd, entry->fmtetc.ptd))
+        {
+            hr = DV_E_FORMATETC;
+            goto end;
+        }
         mask = fmt->tymed & entry->fmtetc.tymed;
         if(!mask) mask = fmt->tymed & (TYMED_ISTREAM | TYMED_HGLOBAL);
     }
@@ -1125,6 +1160,7 @@ static HRESULT WINAPI snapshot_GetData(IDataObject *iface, FORMATETC *fmt,
     }
 
 end:
+    HeapFree(GetProcessHeap(), 0, enum_data);
     if ( !CloseClipboard() ) hr = CLIPBRD_E_CANT_CLOSE;
     return hr;
 }
diff --git a/dlls/ole32/tests/clipboard.c b/dlls/ole32/tests/clipboard.c
index ed47c8b..51b3a62 100644
--- a/dlls/ole32/tests/clipboard.c
+++ b/dlls/ole32/tests/clipboard.c
@@ -1118,7 +1118,7 @@ static void test_flushed_getdata(void)
 
     InitFormatEtc(fmt, cf_another, 0xffff);
     hr = IDataObject_GetData(get, &fmt, &med);
-    todo_wine ok(hr == DV_E_FORMATETC, "got %08x\n", hr);
+    ok(hr == DV_E_FORMATETC, "got %08x\n", hr);
 
     InitFormatEtc(fmt, cf_another, 0xffff);
     memset(&dm, 0, sizeof(dm));




More information about the wine-cvs mailing list