diff --git a/dlls/ole32/compobj_private.h b/dlls/ole32/compobj_private.h index 6488287c802..8bab8193b42 100644 --- a/dlls/ole32/compobj_private.h +++ b/dlls/ole32/compobj_private.h @@ -334,4 +334,16 @@ static inline BOOL heap_free(void *mem) return HeapFree(GetProcessHeap(), 0, mem); } +static inline HRESULT copy_formatetc(FORMATETC *dst, const FORMATETC *src) +{ + *dst = *src; + if (src->ptd) + { + dst->ptd = CoTaskMemAlloc( src->ptd->tdSize ); + if (!dst->ptd) return E_OUTOFMEMORY; + memcpy( dst->ptd, src->ptd, src->ptd->tdSize ); + } + return S_OK; +} + #endif /* __WINE_OLE_COMPOBJ_H */ diff --git a/dlls/ole32/oleobj.c b/dlls/ole32/oleobj.c index edbef554c52..17ab8d0e142 100644 --- a/dlls/ole32/oleobj.c +++ b/dlls/ole32/oleobj.c @@ -56,14 +56,14 @@ static void release_statdata(STATDATA *data) static HRESULT copy_statdata(STATDATA *dst, const STATDATA *src) { - *dst = *src; - if(src->formatetc.ptd) - { - dst->formatetc.ptd = CoTaskMemAlloc(src->formatetc.ptd->tdSize); - if(!dst->formatetc.ptd) return E_OUTOFMEMORY; - memcpy(dst->formatetc.ptd, src->formatetc.ptd, src->formatetc.ptd->tdSize); - } - if(dst->pAdvSink) IAdviseSink_AddRef(dst->pAdvSink); + HRESULT hr; + + hr = copy_formatetc( &dst->formatetc, &src->formatetc ); + if (FAILED(hr)) return hr; + dst->advf = src->advf; + dst->pAdvSink = src->pAdvSink; + if (dst->pAdvSink) IAdviseSink_AddRef( dst->pAdvSink ); + dst->dwConnection = src->dwConnection; return S_OK; }