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

Unified Diff: chrome/browser/ui/webui/favicon_source.cc

Issue 11576030: Add size checks to extension icons to prevent out of memory conditions (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years 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
Index: chrome/browser/ui/webui/favicon_source.cc
===================================================================
--- chrome/browser/ui/webui/favicon_source.cc (revision 173105)
+++ chrome/browser/ui/webui/favicon_source.cc (working copy)
@@ -17,6 +17,8 @@
#include "ui/base/layout.h"
#include "ui/base/resource/resource_bundle.h"
+const int kMaxIconSize = 256;
+
FaviconSource::FaviconSource(Profile* profile, IconType type)
: DataSource(type == FAVICON ? chrome::kChromeUIFaviconHost :
chrome::kChromeUITouchIconHost,
@@ -84,6 +86,11 @@
size_in_dip = atoi(size.c_str());
DCHECK(size_in_dip == 64 || size_in_dip == 32 || size_in_dip == 16) <<
Matt Perry 2012/12/14 18:57:08 This DCHECK suggests that we only expect 16, 32, a
"only 64x64, 32x32 and 16x16 icons are supported";
+ if (size_in_dip > kMaxIconSize) {
+ // Note that actual size can be more than kMaxIconSize
+ // because of scale_factor
+ size_in_dip = kMaxIconSize;
+ }
// Optional scale factor.
if (scale_delimiter != std::string::npos && scale_delimiter < slash) {
DCHECK(size_in_dip == 16);

Powered by Google App Engine
This is Rietveld 408576698