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

Side by Side Diff: components/policy/core/browser/android/policy_converter.cc

Issue 2750533003: Temporarily CHECK use after free in Value (Closed)
Patch Set: Fix more Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/policy/core/browser/android/policy_converter.h" 5 #include "components/policy/core/browser/android/policy_converter.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/android/jni_android.h" 10 #include "base/android/jni_android.h"
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 case base::Value::Type::LIST: { 169 case base::Value::Type::LIST: {
170 std::string string_value; 170 std::string string_value;
171 if (value->GetAsString(&string_value)) { 171 if (value->GetAsString(&string_value)) {
172 std::unique_ptr<base::Value> decoded_value = 172 std::unique_ptr<base::Value> decoded_value =
173 base::JSONReader::Read(string_value); 173 base::JSONReader::Read(string_value);
174 if (decoded_value) 174 if (decoded_value)
175 return decoded_value; 175 return decoded_value;
176 } 176 }
177 return value; 177 return value;
178 } 178 }
179 case base::Value::Type::DELETED: {
180 // TODO(crbug.com/697817): This means a use-after-free.
181 CHECK(false);
182 return nullptr;
183 }
179 } 184 }
180 185
181 NOTREACHED(); 186 NOTREACHED();
182 return std::unique_ptr<base::Value>(); 187 return std::unique_ptr<base::Value>();
183 } 188 }
184 189
185 // static 190 // static
186 bool PolicyConverter::Register(JNIEnv* env) { 191 bool PolicyConverter::Register(JNIEnv* env) {
187 return RegisterNativesImpl(env); 192 return RegisterNativesImpl(env);
188 } 193 }
189 194
190 void PolicyConverter::SetPolicyValue(const std::string& key, 195 void PolicyConverter::SetPolicyValue(const std::string& key,
191 std::unique_ptr<base::Value> value) { 196 std::unique_ptr<base::Value> value) {
192 const Schema schema = policy_schema_->GetKnownProperty(key); 197 const Schema schema = policy_schema_->GetKnownProperty(key);
193 const PolicyNamespace ns(POLICY_DOMAIN_CHROME, std::string()); 198 const PolicyNamespace ns(POLICY_DOMAIN_CHROME, std::string());
194 policy_bundle_->Get(ns).Set( 199 policy_bundle_->Get(ns).Set(
195 key, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, POLICY_SOURCE_PLATFORM, 200 key, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, POLICY_SOURCE_PLATFORM,
196 ConvertValueToSchema(std::move(value), schema), nullptr); 201 ConvertValueToSchema(std::move(value), schema), nullptr);
197 } 202 }
198 203
199 } // namespace android 204 } // namespace android
200 } // namespace policy 205 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/applescript/apple_event_util.mm ('k') | components/policy/core/common/policy_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698