Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(356)

Unified Diff: chrome/browser/icon_loader_win.cc

Issue 7753009: In icon_loader_win.cc, if CreateSkBitmapFromHICON fails, don't pass NULL to gfx::Image and crash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Long-time rebase Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/icon_loader_win.cc
diff --git a/chrome/browser/icon_loader_win.cc b/chrome/browser/icon_loader_win.cc
index 48e565f840d6a663c21d5542c85a991500ad2c7c..8a167acbae3e057ecb1ca02e6403788e7c80e2f5 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));
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698