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

Side by Side Diff: runtime/vm/hash_map.h

Issue 2729813004: Fixes issue #28904 and issue #28901. Fixed an out of range array access in the hash map Iterator::N… (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 | « no previous file | 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 Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef RUNTIME_VM_HASH_MAP_H_ 5 #ifndef RUNTIME_VM_HASH_MAP_H_
6 #define RUNTIME_VM_HASH_MAP_H_ 6 #define RUNTIME_VM_HASH_MAP_H_
7 7
8 #include "vm/growable_array.h" // For Malloc, EmptyBase 8 #include "vm/growable_array.h" // For Malloc, EmptyBase
9 #include "vm/zone.h" 9 #include "vm/zone.h"
10 10
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 168
169 template <typename KeyValueTrait, typename B, typename Allocator> 169 template <typename KeyValueTrait, typename B, typename Allocator>
170 typename KeyValueTrait::Pair* 170 typename KeyValueTrait::Pair*
171 BaseDirectChainedHashMap<KeyValueTrait, B, Allocator>::Iterator::Next() { 171 BaseDirectChainedHashMap<KeyValueTrait, B, Allocator>::Iterator::Next() {
172 const typename KeyValueTrait::Value kNoValue = 172 const typename KeyValueTrait::Value kNoValue =
173 KeyValueTrait::ValueOf(typename KeyValueTrait::Pair()); 173 KeyValueTrait::ValueOf(typename KeyValueTrait::Pair());
174 174
175 if (array_index_ < map_.array_size_) { 175 if (array_index_ < map_.array_size_) {
176 // If we're not in the middle of a list, find the next array slot. 176 // If we're not in the middle of a list, find the next array slot.
177 if (list_index_ == kNil) { 177 if (list_index_ == kNil) {
178 while (KeyValueTrait::ValueOf(map_.array_[array_index_].kv) == kNoValue && 178 while (array_index_ < map_.array_size_ &&
zra 2017/03/03 18:03:54 Please put parens around the < and == clauses.
179 array_index_ < map_.array_size_) { 179 KeyValueTrait::ValueOf(map_.array_[array_index_].kv) == kNoValue) {
180 array_index_++; 180 array_index_++;
181 } 181 }
182 if (array_index_ < map_.array_size_) { 182 if (array_index_ < map_.array_size_) {
183 // When we're done with the list, we'll continue with the next array 183 // When we're done with the list, we'll continue with the next array
184 // slot. 184 // slot.
185 const intptr_t old_array_index = array_index_; 185 const intptr_t old_array_index = array_index_;
186 array_index_++; 186 array_index_++;
187 list_index_ = map_.array_[old_array_index].next; 187 list_index_ = map_.array_[old_array_index].next;
188 return &map_.array_[old_array_index].kv; 188 return &map_.array_[old_array_index].kv;
189 } else { 189 } else {
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 437
438 static Key KeyOf(Pair kv) { return kv.key; } 438 static Key KeyOf(Pair kv) { return kv.key; }
439 static Value ValueOf(Pair kv) { return kv.value; } 439 static Value ValueOf(Pair kv) { return kv.value; }
440 static intptr_t Hashcode(Key key) { return reinterpret_cast<intptr_t>(key); } 440 static intptr_t Hashcode(Key key) { return reinterpret_cast<intptr_t>(key); }
441 static bool IsKeyEqual(Pair kv, Key key) { return kv.key == key; } 441 static bool IsKeyEqual(Pair kv, Key key) { return kv.key == key; }
442 }; 442 };
443 443
444 } // namespace dart 444 } // namespace dart
445 445
446 #endif // RUNTIME_VM_HASH_MAP_H_ 446 #endif // RUNTIME_VM_HASH_MAP_H_
OLDNEW
« 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