From a88626151868a55925d613ccdd21fe3191d368a5 Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Mon, 27 Jun 2016 14:38:12 +0200 Subject: [PATCH] Fix crash in ReadImageSkiaFromICO when CreateSkBitmapFromHICON fails --- atom/common/api/atom_api_native_image.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/atom/common/api/atom_api_native_image.cc b/atom/common/api/atom_api_native_image.cc index b666f86..1450049 100644 --- a/atom/common/api/atom_api_native_image.cc +++ b/atom/common/api/atom_api_native_image.cc @@ -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 bitmap(IconUtil::CreateSkBitmapFromHICON(icon)); + if (!bitmap) + return false; + image->AddRepresentation(gfx::ImageSkiaRep(*bitmap, 1.0f)); + return true; } #endif -- 2.7.4