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

Unified Diff: src/core/SkTDynamicHash.h

Issue 380443002: Add bounds checks to SkTDynamicHash (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 5 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: src/core/SkTDynamicHash.h
diff --git a/src/core/SkTDynamicHash.h b/src/core/SkTDynamicHash.h
index c9a0b3ed01cfaa24cb3851f8fe9cd5c2125af2dd..445a45df8580c74bd096a7ec2e74f3bea135c5b9 100644
--- a/src/core/SkTDynamicHash.h
+++ b/src/core/SkTDynamicHash.h
@@ -63,6 +63,7 @@ public:
T* find(const Key& key) const {
int index = this->firstIndex(key);
for (int round = 0; round < fCapacity; round++) {
+ SkASSERT(index >= 0 && index < fCapacity);
T* candidate = fArray[index];
if (Empty() == candidate) {
return NULL;
@@ -100,6 +101,7 @@ protected:
int countCollisions(const Key& key) const {
int index = this->firstIndex(key);
for (int round = 0; round < fCapacity; round++) {
+ SkASSERT(index >= 0 && index < fCapacity);
const T* candidate = fArray[index];
if (Empty() == candidate || Deleted() == candidate || GetKey(*candidate) == key) {
return round;
@@ -163,6 +165,7 @@ private:
const Key& key = GetKey(*newEntry);
int index = this->firstIndex(key);
for (int round = 0; round < fCapacity; round++) {
+ SkASSERT(index >= 0 && index < fCapacity);
const T* candidate = fArray[index];
if (Empty() == candidate || Deleted() == candidate) {
if (Deleted() == candidate) {
@@ -181,6 +184,7 @@ private:
const int firstIndex = this->firstIndex(key);
int index = firstIndex;
for (int round = 0; round < fCapacity; round++) {
+ SkASSERT(index >= 0 && index < fCapacity);
const T* candidate = fArray[index];
if (Deleted() != candidate && GetKey(*candidate) == key) {
fDeleted++;
« 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