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

Unified Diff: chrome/browser/content_settings/host_content_settings_map.cc

Issue 8528031: Fix memory leak in SetDefaultContentSettings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix memory leaks Created 9 years, 1 month 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 | « chrome/browser/content_settings/content_settings_default_provider.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/content_settings/host_content_settings_map.cc
diff --git a/chrome/browser/content_settings/host_content_settings_map.cc b/chrome/browser/content_settings/host_content_settings_map.cc
index 39c38a939349651c70d02e0a1759414851fc117a..ae2dfc2721e08d8767aaba5a4a8d25fab5780132 100644
--- a/chrome/browser/content_settings/host_content_settings_map.cc
+++ b/chrome/browser/content_settings/host_content_settings_map.cc
@@ -210,12 +210,15 @@ void HostContentSettingsMap::SetDefaultContentSetting(
DCHECK_NE(content_type, CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE);
DCHECK(IsSettingAllowedForType(setting, content_type));
- base::Value* value = Value::CreateIntegerValue(setting);
- if (!content_settings_providers_[DEFAULT_PROVIDER]->SetWebsiteSetting(
- ContentSettingsPattern::Wildcard(), ContentSettingsPattern::Wildcard(),
- content_type, std::string(), value)) {
- delete value;
- }
+ base::Value* value = NULL;
+ if (setting != CONTENT_SETTING_DEFAULT)
+ value = Value::CreateIntegerValue(setting);
+ SetWebsiteSetting(
+ ContentSettingsPattern::Wildcard(),
+ ContentSettingsPattern::Wildcard(),
+ content_type,
+ std::string(),
+ value);
Bernhard Bauer 2011/11/18 16:32:42 You should still check the return value for the ca
Bernhard Bauer 2011/11/18 16:44:44 Uh, disregard this, I thought that SetWebsiteSetti
}
void HostContentSettingsMap::SetWebsiteSetting(
@@ -238,6 +241,12 @@ void HostContentSettingsMap::SetWebsiteSetting(
return;
}
}
+ // There should be at least one provider that accepts the ownership of the
James Hawkins 2011/11/18 16:39:44 Eh I'm not so sure about this. This falls under th
Bernhard Bauer 2011/11/18 16:44:44 Hm, but shouldn't the right way to catch this be a
James Hawkins 2011/11/18 16:53:40 Yes, you're right; however, my original complaint
markusheintz_ 2011/11/18 17:01:18 The NOTREACHED is really not reached. I don't know
markusheintz_ 2011/11/18 21:04:31 If you like we can change the NOTREACHED() to a CH
James Hawkins 2011/11/18 21:07:23 There's no need to change the NOTREACHED(). If it'
+ // passed |value|. However if we would set a default setting on the incognito
+ // map the |DefaultProvider| would refuse to accept the setting. This should
+ // not happen that's why there is the NOTREACHED. However if it would happen,
+ // then we do not want to leak memory. Hence delete the |value|.
+ delete value;
NOTREACHED();
}
« no previous file with comments | « chrome/browser/content_settings/content_settings_default_provider.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698