[ATL] CImage::Load(): Return E_FAIL without ATLASSERT on failure (#4993)
authorRatin Gao <ratin@knsoft.org>
Sun, 22 Jan 2023 17:38:16 +0000 (01:38 +0800)
committerGitHub <noreply@github.com>
Sun, 22 Jan 2023 17:38:16 +0000 (20:38 +0300)
Application won't be interrupted by ATLASSERT when image load failure happens,
just like it was done in MS ATL.

CORE-18589

sdk/lib/atl/atlimage.h

index f124c9a..f84d8cb 100644 (file)
@@ -382,8 +382,10 @@ public:
         // create a GpBitmap object from file
         using namespace Gdiplus;
         GpBitmap *pBitmap = NULL;
-        GetCommon().CreateBitmapFromFile(pszNameW, &pBitmap);
-        ATLASSERT(pBitmap);
+        if (GetCommon().CreateBitmapFromFile(pszNameW, &pBitmap) != Ok)
+        {
+            return E_FAIL;
+        }
 
         // TODO & FIXME: get parameters (m_rgbTransColor etc.)
 
@@ -407,8 +409,10 @@ public:
         // create GpBitmap from stream
         using namespace Gdiplus;
         GpBitmap *pBitmap = NULL;
-        GetCommon().CreateBitmapFromStream(pStream, &pBitmap);
-        ATLASSERT(pBitmap);
+        if (GetCommon().CreateBitmapFromStream(pStream, &pBitmap) != Ok)
+        {
+            return E_FAIL;
+        }
 
         // TODO & FIXME: get parameters (m_rgbTransColor etc.)