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

Unified Diff: base/metrics/histogram.cc

Issue 6542034: Fix for crash in histogram BucketIndex (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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 | « base/metrics/histogram.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/histogram.cc
===================================================================
--- base/metrics/histogram.cc (revision 75722)
+++ base/metrics/histogram.cc (working copy)
@@ -23,6 +23,9 @@
typedef Histogram::Count Count;
+// static
+const size_t Histogram::kBucketCount_MAX = 10000u;
+
scoped_refptr<Histogram> Histogram::FactoryGet(const std::string& name,
Sample minimum, Sample maximum, size_t bucket_count, Flags flags) {
scoped_refptr<Histogram> histogram(NULL);
@@ -413,7 +416,7 @@
do {
DCHECK_GE(over, under);
- mid = (over + under)/2;
+ mid = under + (over - under)/2;
if (mid == under)
break;
if (ranges(mid) <= value)
@@ -423,7 +426,7 @@
} while (true);
DCHECK_LE(ranges(mid), value);
- DCHECK_GT(ranges(mid+1), value);
+ CHECK_GT(ranges(mid+1), value);
return mid;
}
@@ -483,6 +486,7 @@
declared_max_ = kSampleType_MAX - 1;
DCHECK_LE(declared_min_, declared_max_);
DCHECK_GT(bucket_count_, 1u);
+ CHECK_LT(bucket_count_, kBucketCount_MAX);
size_t maximal_bucket_count = declared_max_ - declared_min_ + 2;
DCHECK_LE(bucket_count_, maximal_bucket_count);
DCHECK_EQ(0, ranges_[0]);
« no previous file with comments | « base/metrics/histogram.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698