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

Unified Diff: base/values.cc

Issue 2728773005: Check Swaps and MergeDictionary for base::Value (Closed)
Patch Set: CHECKS Created 3 years, 10 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: base/values.cc
diff --git a/base/values.cc b/base/values.cc
index 9aa04f33c64b1cc1eee031f1e89b03ed7b5bb358..8172c48c5938b3e870e83e8d0c012de880ff6681 100644
--- a/base/values.cc
+++ b/base/values.cc
@@ -535,7 +535,7 @@ void Value::InternalMoveConstructFrom(Value&& that) {
}
void Value::InternalCopyAssignFrom(const Value& that) {
- type_ = that.type_;
+ CHECK_EQ(type_, that.type_);
jdoerrie 2017/03/06 12:34:43 You could add a comment here that this does not pr
vabr (Chromium) 2017/03/06 17:09:32 Yes, it is confusing. In fact, as I studied the cr
switch (type_) {
case Type::NONE:
@@ -565,7 +565,7 @@ void Value::InternalCopyAssignFrom(const Value& that) {
}
void Value::InternalMoveAssignFrom(Value&& that) {
- type_ = that.type_;
+ CHECK_EQ(type_, that.type_);
jdoerrie 2017/03/06 12:34:43 See above (s/copy/move).
vabr (Chromium) 2017/03/06 17:09:32 Done.
switch (type_) {
case Type::NONE:
@@ -1038,6 +1038,7 @@ std::unique_ptr<DictionaryValue> DictionaryValue::DeepCopyWithoutEmptyChildren()
}
void DictionaryValue::MergeDictionary(const DictionaryValue* dictionary) {
+ CHECK(dictionary->is_dict());
for (DictionaryValue::Iterator it(*dictionary); !it.IsAtEnd(); it.Advance()) {
const Value* merge_value = &it.value();
// Check whether we have to merge dictionaries.
@@ -1056,6 +1057,7 @@ void DictionaryValue::MergeDictionary(const DictionaryValue* dictionary) {
}
void DictionaryValue::Swap(DictionaryValue* other) {
+ CHECK(other->is_dict());
dict_ptr_->swap(*(other->dict_ptr_));
}
@@ -1330,6 +1332,7 @@ ListValue::const_iterator ListValue::Find(const Value& value) const {
}
void ListValue::Swap(ListValue* other) {
+ CHECK(other->is_list());
list_->swap(*(other->list_));
}
« 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