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

Unified Diff: base/metrics/sample_vector.cc

Issue 2853853002: Fix overflow when logging MaxInt32 to a sparse histogram. (Closed)
Patch Set: Created 3 years, 8 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
Index: base/metrics/sample_vector.cc
diff --git a/base/metrics/sample_vector.cc b/base/metrics/sample_vector.cc
index b55449d245be4089b39973c2f3c12414865433ad..c9b7a40ee77e04b3d2ddbed16987c5630032052e 100644
--- a/base/metrics/sample_vector.cc
+++ b/base/metrics/sample_vector.cc
@@ -132,7 +132,7 @@ bool SampleVectorBase::AddSubtractImpl(SampleCountIterator* iter,
// Get the first value and its index.
HistogramBase::Sample min;
- HistogramBase::Sample max;
+ int64_t max;
HistogramBase::Count count;
iter->Get(&min, &max, &count);
size_t dest_index = GetBucketIndex(min);
@@ -392,13 +392,13 @@ void SampleVectorIterator::Next() {
}
void SampleVectorIterator::Get(HistogramBase::Sample* min,
- HistogramBase::Sample* max,
+ int64_t* max,
HistogramBase::Count* count) const {
DCHECK(!Done());
if (min != NULL)
*min = bucket_ranges_->range(index_);
if (max != NULL)
- *max = bucket_ranges_->range(index_ + 1);
+ *max = static_cast<int64_t>(bucket_ranges_->range(index_ + 1));
if (count != NULL)
*count = subtle::NoBarrier_Load(&counts_[index_]);
}

Powered by Google App Engine
This is Rietveld 408576698