diff --git a/dlls/oleaut32/olepicture.c b/dlls/oleaut32/olepicture.c index ac8b2072071..da71946a403 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.