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

Side by Side Diff: base/values.cc

Issue 2743363004: Temporarily CHECK use after free in Value (Closed)
Patch Set: 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
« no previous file with comments | « base/values.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/values.h" 5 #include "base/values.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 InternalCleanup(); 193 InternalCleanup();
194 InternalMoveConstructFrom(std::move(that)); 194 InternalMoveConstructFrom(std::move(that));
195 } 195 }
196 } 196 }
197 197
198 return *this; 198 return *this;
199 } 199 }
200 200
201 Value::~Value() { 201 Value::~Value() {
202 InternalCleanup(); 202 InternalCleanup();
203 alive_ = false;
203 } 204 }
204 205
205 // static 206 // static
206 const char* Value::GetTypeName(Value::Type type) { 207 const char* Value::GetTypeName(Value::Type type) {
207 DCHECK_GE(static_cast<int>(type), 0); 208 DCHECK_GE(static_cast<int>(type), 0);
208 DCHECK_LT(static_cast<size_t>(type), arraysize(kTypeNames)); 209 DCHECK_LT(static_cast<size_t>(type), arraysize(kTypeNames));
209 return kTypeNames[static_cast<size_t>(type)]; 210 return kTypeNames[static_cast<size_t>(type)];
210 } 211 }
211 212
212 bool Value::GetBool() const { 213 bool Value::GetBool() const {
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 case Type::DICTIONARY: 583 case Type::DICTIONARY:
583 *dict_ptr_ = std::move(*that.dict_ptr_); 584 *dict_ptr_ = std::move(*that.dict_ptr_);
584 return; 585 return;
585 case Type::LIST: 586 case Type::LIST:
586 *list_ = std::move(*that.list_); 587 *list_ = std::move(*that.list_);
587 return; 588 return;
588 } 589 }
589 } 590 }
590 591
591 void Value::InternalCleanup() { 592 void Value::InternalCleanup() {
593 CHECK(alive_);
594
592 switch (type_) { 595 switch (type_) {
593 case Type::NONE: 596 case Type::NONE:
594 case Type::BOOLEAN: 597 case Type::BOOLEAN:
595 case Type::INTEGER: 598 case Type::INTEGER:
596 case Type::DOUBLE: 599 case Type::DOUBLE:
597 // Nothing to do 600 // Nothing to do
598 return; 601 return;
599 602
600 case Type::STRING: 603 case Type::STRING:
601 string_value_.Destroy(); 604 string_value_.Destroy();
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after
1355 } 1358 }
1356 1359
1357 std::ostream& operator<<(std::ostream& out, const Value::Type& type) { 1360 std::ostream& operator<<(std::ostream& out, const Value::Type& type) {
1358 if (static_cast<int>(type) < 0 || 1361 if (static_cast<int>(type) < 0 ||
1359 static_cast<size_t>(type) >= arraysize(kTypeNames)) 1362 static_cast<size_t>(type) >= arraysize(kTypeNames))
1360 return out << "Invalid Type (index = " << static_cast<int>(type) << ")"; 1363 return out << "Invalid Type (index = " << static_cast<int>(type) << ")";
1361 return out << Value::GetTypeName(type); 1364 return out << Value::GetTypeName(type);
1362 } 1365 }
1363 1366
1364 } // namespace base 1367 } // namespace base
OLDNEW
« no previous file with comments | « base/values.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698