Robert Shearman : ole32: Allocate memory for a copy of the ptd member of FORMATETC in

Alexandre Julliard julliard at wine.codeweavers.com
Thu Sep 7 05:07:25 CDT 2006


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

Author: Robert Shearman <rob at codeweavers.com>
Date:   Thu Aug 31 17:21:13 2006 +0100

ole32: Allocate memory for a copy of the ptd member of FORMATETC in
DataAdviseHolder_Advise since there is no requirement for the
application to keep this memory valid for the lifetime of the
connection.

---

 dlls/ole32/oleobj.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/dlls/ole32/oleobj.c b/dlls/ole32/oleobj.c
index ae06f18..a7470e4 100644
--- a/dlls/ole32/oleobj.c
+++ b/dlls/ole32/oleobj.c
@@ -723,8 +723,18 @@ static HRESULT WINAPI DataAdviseHolder_A
    * Store the new sink
    */
   This->Connections[index].sink = pAdvise;
-  memcpy(&(This->Connections[index].fmat), pFetc, sizeof(FORMATETC));
   This->Connections[index].advf = advf & ~WINE_ADVF_REMOTE;
+  memcpy(&(This->Connections[index].fmat), pFetc, sizeof(FORMATETC));
+  if (pFetc->ptd)
+  {
+    This->Connections[index].fmat.ptd = CoTaskMemAlloc(pFetc->ptd->tdSize);
+    if (!This->Connections[index].fmat.ptd)
+    {
+      IDataAdviseHolder_Unadvise(iface, index + 1);
+      return E_OUTOFMEMORY;
+    }
+    memcpy(This->Connections[index].fmat.ptd, pFetc->ptd, pFetc->ptd->tdSize);
+  }
 
   if (This->Connections[index].sink != NULL) {
     IAdviseSink_AddRef(This->Connections[index].sink);




More information about the wine-cvs mailing list