Fix crash in ReadImageSkiaFromICO when CreateSkBitmapFromHICON fails
authorMilan Burda <milan.burda@gmail.com>
Mon, 27 Jun 2016 12:38:12 +0000 (14:38 +0200)
committerKevin Sawicki <kevinsawicki@gmail.com>
Tue, 28 Jun 2016 19:17:05 +0000 (12:17 -0700)
atom/common/api/atom_api_native_image.cc

index b666f86..1450049 100644 (file)
@@ -160,10 +160,14 @@ base::win::ScopedHICON ReadICOFromPath(int size, const base::FilePath& path) {
                 LR_LOADFROMFILE)));
 }
 
-void ReadImageSkiaFromICO(gfx::ImageSkia* image, HICON icon) {
+bool ReadImageSkiaFromICO(gfx::ImageSkia* image, HICON icon) {
   // Convert the icon from the Windows specific HICON to gfx::ImageSkia.
   std::unique_ptr<SkBitmap> bitmap(IconUtil::CreateSkBitmapFromHICON(icon));
+  if (!bitmap)
+    return false;
+
   image->AddRepresentation(gfx::ImageSkiaRep(*bitmap, 1.0f));
+  return true;
 }
 #endif