Huw Davies : ole32: Fix incorrectly assigned member in the presentation stream.

Alexandre Julliard julliard at winehq.org
Tue Jun 6 15:23:31 CDT 2017


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

Author: Huw Davies <huw at codeweavers.com>
Date:   Tue Jun  6 11:46:48 2017 +0100

ole32: Fix incorrectly assigned member in the presentation stream.

Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ole32/datacache.c  | 36 ++++++++++++++++++++++++------------
 dlls/ole32/tests/ole2.c | 16 +++++++---------
 2 files changed, 31 insertions(+), 21 deletions(-)

diff --git a/dlls/ole32/datacache.c b/dlls/ole32/datacache.c
index b6c227e..d921603 100644
--- a/dlls/ole32/datacache.c
+++ b/dlls/ole32/datacache.c
@@ -82,7 +82,7 @@ typedef struct PresentationDataHeader
   DWORD unknown3;	/* 4, possibly TYMED_ISTREAM */
   DVASPECT dvAspect;
   DWORD lindex;
-  DWORD tymed;
+  DWORD advf;
   DWORD unknown7;	/* 0 */
   DWORD dwObjectExtentX;
   DWORD dwObjectExtentY;
@@ -320,10 +320,10 @@ static DataCacheEntry *DataCache_GetEntryForFormatEtc(DataCache *This, const FOR
 /* 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, BOOL load)
+static HRESULT check_valid_clipformat_and_tymed(CLIPFORMAT cfFormat, DWORD tymed)
 {
     if (!cfFormat || !tymed ||
-        (cfFormat == CF_METAFILEPICT && (tymed == TYMED_MFPICT || load)) ||
+        (cfFormat == CF_METAFILEPICT && tymed == TYMED_MFPICT) ||
         (cfFormat == CF_BITMAP && tymed == TYMED_GDI) ||
         (cfFormat == CF_DIB && tymed == TYMED_HGLOBAL) ||
         (cfFormat == CF_ENHMETAFILE && tymed == TYMED_ENHMF))
@@ -360,11 +360,11 @@ static BOOL init_cache_entry(DataCacheEntry *entry, const FORMATETC *fmt, DWORD
 }
 
 static HRESULT DataCache_CreateEntry(DataCache *This, const FORMATETC *formatetc, DWORD advf,
-                                     DataCacheEntry **cache_entry, BOOL load)
+                                     DataCacheEntry **cache_entry)
 {
     HRESULT hr;
 
-    hr = check_valid_clipformat_and_tymed(formatetc->cfFormat, formatetc->tymed, load);
+    hr = check_valid_clipformat_and_tymed(formatetc->cfFormat, formatetc->tymed);
     if (FAILED(hr))
         return hr;
     if (hr == CACHE_S_FORMATETC_NOTSUPPORTED)
@@ -798,7 +798,7 @@ static HRESULT DataCacheEntry_Save(DataCacheEntry *cache_entry, IStorage *storag
     header.unknown3 = 4;
     header.dvAspect = cache_entry->fmtetc.dwAspect;
     header.lindex = cache_entry->fmtetc.lindex;
-    header.tymed = cache_entry->stgmedium.tymed;
+    header.advf = cache_entry->advise_flags;
     header.unknown7 = 0;
     header.dwObjectExtentX = 0;
     header.dwObjectExtentY = 0;
@@ -1028,6 +1028,18 @@ static inline void DataCacheEntry_HandsOffStorage(DataCacheEntry *cache_entry)
     }
 }
 
+static inline DWORD tymed_from_cf( DWORD cf )
+{
+    switch( cf )
+    {
+    case CF_BITMAP:       return TYMED_GDI;
+    case CF_METAFILEPICT: return TYMED_MFPICT;
+    case CF_ENHMETAFILE:  return TYMED_ENHMF;
+    case CF_DIB:
+    default:              return TYMED_HGLOBAL;
+    }
+}
+
 /*********************************************************
  * Method implementation for the  non delegating IUnknown
  * part of the DataCache class.
@@ -1416,7 +1428,7 @@ static HRESULT WINAPI DataCache_InitNew(
 }
 
 
-static HRESULT add_cache_entry( DataCache *This, const FORMATETC *fmt, IStream *stm,
+static HRESULT add_cache_entry( DataCache *This, const FORMATETC *fmt, DWORD advf, IStream *stm,
                                 enum stream_type type )
 {
     DataCacheEntry *cache_entry;
@@ -1426,7 +1438,7 @@ static HRESULT add_cache_entry( DataCache *This, const FORMATETC *fmt, IStream *
 
     cache_entry = DataCache_GetEntryForFormatEtc( This, fmt );
     if (!cache_entry)
-        hr = DataCache_CreateEntry( This, fmt, 0, &cache_entry, TRUE );
+        hr = DataCache_CreateEntry( This, fmt, advf, &cache_entry );
     if (SUCCEEDED( hr ))
     {
         DataCacheEntry_DiscardData( cache_entry );
@@ -1472,9 +1484,9 @@ static HRESULT parse_pres_streams( DataCache *This, IStorage *stg )
                     fmtetc.ptd = NULL; /* FIXME */
                     fmtetc.dwAspect = header.dvAspect;
                     fmtetc.lindex = header.lindex;
-                    fmtetc.tymed = header.tymed;
+                    fmtetc.tymed = tymed_from_cf( clipformat );
 
-                    add_cache_entry( This, &fmtetc, stm, pres_stream );
+                    add_cache_entry( This, &fmtetc, header.advf, stm, pres_stream );
                 }
                 IStream_Release( stm );
             }
@@ -1505,7 +1517,7 @@ static HRESULT parse_contents_stream( DataCache *This, IStorage *stg, IStream *s
         return E_FAIL;
     }
 
-    return add_cache_entry( This, fmt, stm, contents_stream );
+    return add_cache_entry( This, fmt, 0, stm, contents_stream );
 }
 
 static const WCHAR CONTENTS[] = {'C','O','N','T','E','N','T','S',0};
@@ -2177,7 +2189,7 @@ static HRESULT WINAPI DataCache_Cache(
         return CACHE_S_SAMECACHE;
     }
 
-    hr = DataCache_CreateEntry(This, &fmt_cpy, advf, &cache_entry, FALSE);
+    hr = DataCache_CreateEntry(This, &fmt_cpy, advf, &cache_entry);
 
     if (SUCCEEDED(hr))
     {
diff --git a/dlls/ole32/tests/ole2.c b/dlls/ole32/tests/ole2.c
index 394371b..37e89da 100644
--- a/dlls/ole32/tests/ole2.c
+++ b/dlls/ole32/tests/ole2.c
@@ -135,7 +135,7 @@ typedef struct PresentationDataHeader
     DWORD unknown3; /* 4, possibly TYMED_ISTREAM */
     DVASPECT dvAspect;
     DWORD lindex;
-    DWORD tymed;
+    DWORD advf;
     DWORD unknown7; /* 0 */
     DWORD dwObjectExtentX;
     DWORD dwObjectExtentY;
@@ -1173,7 +1173,7 @@ static void test_OleLoad(IStorage *pStorage)
         IStorage *stg;
         IStream *stream;
         IUnknown *obj;
-        DWORD data, i, tymed, data_size;
+        DWORD data, i, data_size;
         PresentationDataHeader header;
         HDC hdc;
         HGDIOBJ hobj;
@@ -1222,12 +1222,10 @@ static void test_OleLoad(IStorage *pStorage)
                 break;
             }
 
-            tymed = 1 << i;
-
             header.unknown3 = 4;
             header.dvAspect = DVASPECT_CONTENT;
             header.lindex = -1;
-            header.tymed = tymed;
+            header.advf = 1 << i;
             header.unknown7 = 0;
             header.dwObjectExtentX = 1;
             header.dwObjectExtentY = 1;
@@ -1247,19 +1245,19 @@ static void test_OleLoad(IStorage *pStorage)
                 IStorage_Release(stg);
                 continue;
             }
-            ok(hr == S_OK, "OleLoad error %#x: cfFormat = %u, tymed = %u\n", hr, fmt, tymed);
+            ok(hr == S_OK, "OleLoad error %#x: cfFormat = %u, advf = %#x\n", hr, fmt, header.advf);
 
             hdc = CreateCompatibleDC(0);
             SetRect(&rc, 0, 0, 100, 100);
             hr = OleDraw(obj, DVASPECT_CONTENT, hdc, &rc);
             DeleteDC(hdc);
             if (fmt == CF_METAFILEPICT)
-                ok(hr == S_OK, "OleDraw error %#x: cfFormat = %u, tymed = %u\n", hr, fmt, tymed);
+                ok(hr == S_OK, "OleDraw error %#x: cfFormat = %u, advf = %#x\n", hr, fmt, header.advf);
             else if (fmt == CF_ENHMETAFILE)
 todo_wine
-                ok(hr == S_OK, "OleDraw error %#x: cfFormat = %u, tymed = %u\n", hr, fmt, tymed);
+                ok(hr == S_OK, "OleDraw error %#x: cfFormat = %u, advf = %#x\n", hr, fmt, header.advf);
             else
-                ok(hr == OLE_E_BLANK || hr == OLE_E_NOTRUNNING || hr == E_FAIL, "OleDraw should fail: %#x, cfFormat = %u, tymed = %u\n", hr, fmt, header.tymed);
+                ok(hr == OLE_E_BLANK || hr == OLE_E_NOTRUNNING || hr == E_FAIL, "OleDraw should fail: %#x, cfFormat = %u, advf = %#x\n", hr, fmt, header.advf);
 
             IUnknown_Release(obj);
             IStorage_Release(stg);




More information about the wine-cvs mailing list