| Index: chromeos/network/policy_util.cc
|
| diff --git a/chromeos/network/policy_util.cc b/chromeos/network/policy_util.cc
|
| index b28f30bee2834a4a3856427405438044b4dd9cdb..ebea93e02b28221da0e237f715118fb0890355af 100644
|
| --- a/chromeos/network/policy_util.cc
|
| +++ b/chromeos/network/policy_util.cc
|
| @@ -35,18 +35,17 @@ const char kFakeCredential[] = "FAKE_CREDENTIAL_VPaJDV9x";
|
| void RemoveFakeCredentials(
|
| const onc::OncValueSignature& signature,
|
| base::DictionaryValue* onc_object) {
|
| - base::DictionaryValue::Iterator it(*onc_object);
|
| - while (!it.IsAtEnd()) {
|
| - base::Value* value = NULL;
|
| + std::vector<std::string> entries_to_remove;
|
| + for (base::DictionaryValue::Iterator it(*onc_object); !it.IsAtEnd();
|
| + it.Advance()) {
|
| + base::Value* value = nullptr;
|
| std::string field_name = it.key();
|
| // We need the non-const entry to remove nested values but DictionaryValue
|
| // has no non-const iterator.
|
| onc_object->GetWithoutPathExpansion(field_name, &value);
|
| - // Advance before delete.
|
| - it.Advance();
|
|
|
| // If |value| is a dictionary, recurse.
|
| - base::DictionaryValue* nested_object = NULL;
|
| + base::DictionaryValue* nested_object = nullptr;
|
| if (value->GetAsDictionary(&nested_object)) {
|
| const onc::OncFieldSignature* field_signature =
|
| onc::GetFieldSignature(signature, field_name);
|
| @@ -64,12 +63,14 @@ void RemoveFakeCredentials(
|
| if (string_value == kFakeCredential) {
|
| // The value wasn't modified by the UI, thus we remove the field to keep
|
| // the existing value that is stored in Shill.
|
| - onc_object->RemoveWithoutPathExpansion(field_name, NULL);
|
| + entries_to_remove.push_back(field_name);
|
| }
|
| // Otherwise, the value is set and modified by the UI, thus we keep that
|
| // value to overwrite whatever is stored in Shill.
|
| }
|
| }
|
| + for (auto field_name : entries_to_remove)
|
| + onc_object->RemoveWithoutPathExpansion(field_name, nullptr);
|
| }
|
|
|
| // Returns true if |policy| matches |actual_network|, which must be part of a
|
|
|