[PATCH 1/4] oleaut32: Don't accept unsupported picture types in OleCreatePictureIndirect.

Dmitry Timoshkov dmitry at baikal.ru
Fri Jul 6 03:09:24 CDT 2018


Signed-off-by: Dmitry Timoshkov <dmitry at baikal.ru>
---
 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 ac8b207207..da71946a40 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.
-- 
2.17.1




More information about the wine-devel mailing list