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

Unified Diff: chrome/browser/prefs/pref_metrics_service.cc

Issue 23903040: Fix memory leak in PrefMetricsService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | « base/values.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/prefs/pref_metrics_service.cc
diff --git a/chrome/browser/prefs/pref_metrics_service.cc b/chrome/browser/prefs/pref_metrics_service.cc
index 803e5a773807787baf76e2dcccf0900898397379..13129b54a42cf663318d09da209051e74c20d84e 100644
--- a/chrome/browser/prefs/pref_metrics_service.cc
+++ b/chrome/browser/prefs/pref_metrics_service.cc
@@ -354,10 +354,12 @@ std::string PrefMetricsService::GetHashedPrefValue(
// Dictionary values may contain empty lists and sub-dictionaries. Create
// a deep copy with those stripped to make the hash more stable.
- DictionaryValue* dict_value =
- static_cast<DictionaryValue*>(const_cast<Value*>(value));
- if (dict_value)
- value = dict_value->DeepCopyWithoutEmptyChildren();
+ scoped_ptr<DictionaryValue> dict_value;
+ if (value->IsType(Value::TYPE_DICTIONARY)) {
+ dict_value.reset(static_cast<const DictionaryValue*>(value)
+ ->DeepCopyWithoutEmptyChildren());
+ value = dict_value.get();
+ }
std::string string_to_hash(device_id_);
string_to_hash.append(path);
« no previous file with comments | « base/values.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698