Module: wine Branch: master Commit: ee08f1cf5b6e24febeda15ce0b9b9f3cb2e884ac URL: https://source.winehq.org/git/wine.git/?a=commit;h=ee08f1cf5b6e24febeda15ce0...
Author: Dmitry Timoshkov dmitry@baikal.ru Date: Fri Jul 6 16:09:24 2018 +0800
oleaut32: Don't accept unsupported picture types in OleCreatePictureIndirect.
Signed-off-by: Dmitry Timoshkov dmitry@baikal.ru Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/oleaut32/olepicture.c | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-)
diff --git a/dlls/oleaut32/olepicture.c b/dlls/oleaut32/olepicture.c index ac8b207..da71946 100644 --- a/dlls/oleaut32/olepicture.c +++ b/dlls/oleaut32/olepicture.c @@ -275,9 +275,10 @@ static void OLEPictureImpl_SetIcon(OLEPictureImpl * This) * The caller of this method must release the object when it's * done with it. */ -static OLEPictureImpl* OLEPictureImpl_Construct(LPPICTDESC pictDesc, BOOL fOwn) +static HRESULT OLEPictureImpl_Construct(LPPICTDESC pictDesc, BOOL fOwn, OLEPictureImpl **pict) { - OLEPictureImpl* newObject = 0; + OLEPictureImpl *newObject; + HRESULT hr;
if (pictDesc) TRACE("(%p) type = %d\n", pictDesc, pictDesc->picType); @@ -286,9 +287,8 @@ static OLEPictureImpl* OLEPictureImpl_Construct(LPPICTDESC pictDesc, BOOL fOwn) * Allocate space for the object. */ newObject = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(OLEPictureImpl)); - - if (newObject==0) - return newObject; + if (!newObject) + return E_OUTOFMEMORY;
/* * Initialize the virtual function table. @@ -299,12 +299,12 @@ static OLEPictureImpl* OLEPictureImpl_Construct(LPPICTDESC pictDesc, BOOL fOwn) newObject->IConnectionPointContainer_iface.lpVtbl = &OLEPictureImpl_IConnectionPointContainer_VTable;
newObject->pCP = NULL; - CreateConnectionPoint((IUnknown*)&newObject->IPicture_iface, &IID_IPropertyNotifySink, + hr = CreateConnectionPoint((IUnknown*)&newObject->IPicture_iface, &IID_IPropertyNotifySink, &newObject->pCP); - if (!newObject->pCP) + if (hr != S_OK) { HeapFree(GetProcessHeap(), 0, newObject); - return NULL; + return hr; }
/* @@ -347,18 +347,24 @@ static OLEPictureImpl* OLEPictureImpl_Construct(LPPICTDESC pictDesc, BOOL fOwn) case PICTYPE_ICON: OLEPictureImpl_SetIcon(newObject); break; + case PICTYPE_ENHMETAFILE: + FIXME("EMF is not supported\n"); + newObject->himetricWidth = newObject->himetricHeight = 0; + break; + default: - FIXME("Unsupported type %d\n", pictDesc->picType); - newObject->himetricWidth = newObject->himetricHeight = 0; - break; + WARN("Unsupported type %d\n", pictDesc->picType); + IPicture_Release(&newObject->IPicture_iface); + return E_UNEXPECTED; } } else { newObject->desc.picType = PICTYPE_UNINITIALIZED; }
TRACE("returning %p\n", newObject); - return newObject; + *pict = newObject; + return S_OK; }
/************************************************************************ @@ -2217,10 +2223,8 @@ HRESULT WINAPI OleCreatePictureIndirect(LPPICTDESC lpPictDesc, REFIID riid,
*ppvObj = NULL;
- newPict = OLEPictureImpl_Construct(lpPictDesc, Own); - - if (newPict == NULL) - return E_OUTOFMEMORY; + hr = OLEPictureImpl_Construct(lpPictDesc, Own, &newPict); + if (hr != S_OK) return hr;
/* * Make sure it supports the interface required by the caller.