diff options
author | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-07 18:43:12 +0000 |
---|---|---|
committer | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-07 18:43:12 +0000 |
commit | ab6d23fe5463f88e7e48147d10447575296f75f9 (patch) | |
tree | 672e2be570be3b2d557e76966f30142ebf9f7c8f /chrome/browser/icon_loader_win.cc | |
parent | de595563f3bc74fc49e072e19d467970e9aff782 (diff) | |
download | chromium_src-ab6d23fe5463f88e7e48147d10447575296f75f9.zip chromium_src-ab6d23fe5463f88e7e48147d10447575296f75f9.tar.gz chromium_src-ab6d23fe5463f88e7e48147d10447575296f75f9.tar.bz2 |
In icon_loader_win.cc, if CreateSkBitmapFromHICON fails, don't pass NULL to gfx::Image and crash.
BUG=92982
TEST=none
Review URL: https://chromiumcodereview.appspot.com/7753009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@155434 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/icon_loader_win.cc')
-rw-r--r-- | chrome/browser/icon_loader_win.cc | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/chrome/browser/icon_loader_win.cc b/chrome/browser/icon_loader_win.cc index 48e565f..8a167ac 100644 --- a/chrome/browser/icon_loader_win.cc +++ b/chrome/browser/icon_loader_win.cc @@ -30,18 +30,24 @@ void IconLoader::ReadIcon() { default: NOTREACHED(); } + + image_.reset(); + SHFILEINFO file_info = { 0 }; - if (!SHGetFileInfo(group_.c_str(), FILE_ATTRIBUTE_NORMAL, &file_info, + if (SHGetFileInfo(group_.c_str(), FILE_ATTRIBUTE_NORMAL, &file_info, sizeof(SHFILEINFO), - SHGFI_ICON | size | SHGFI_USEFILEATTRIBUTES)) - return; + SHGFI_ICON | size | SHGFI_USEFILEATTRIBUTES)) { + scoped_ptr<SkBitmap> bitmap(IconUtil::CreateSkBitmapFromHICON( + file_info.hIcon)); + if (bitmap.get()) { + gfx::ImageSkia image_skia(*bitmap); + image_skia.MakeThreadSafe(); + image_.reset(new gfx::Image(image_skia)); + DestroyIcon(file_info.hIcon); + } + } - scoped_ptr<SkBitmap> bitmap(IconUtil::CreateSkBitmapFromHICON( - file_info.hIcon)); - gfx::ImageSkia image_skia(*bitmap); - image_skia.MakeThreadSafe(); - image_.reset(new gfx::Image(image_skia)); - DestroyIcon(file_info.hIcon); + // Always notify the delegate, regardless of success. target_message_loop_->PostTask(FROM_HERE, base::Bind(&IconLoader::NotifyDelegate, this)); } |