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

Unified Diff: courgette/label_manager.cc

Issue 2528243002: Fix silent truncations when extracting values from CheckedNumeric (Closed)
Patch Set: compile cleanup and fix Created 4 years, 1 month 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: courgette/label_manager.cc
diff --git a/courgette/label_manager.cc b/courgette/label_manager.cc
index 51e0d5de43c945bfb2f7aeb39222586d626b5ce5..c3846cc0e5c6c3ea53772bace35a0309c4d16002 100644
--- a/courgette/label_manager.cc
+++ b/courgette/label_manager.cc
@@ -177,8 +177,8 @@ void LabelManager::Read(RvaVisitor* rva_visitor) {
labels_.reserve(num_distinct_rva);
for (CRV it(rvas.begin(), rvas.end()); it.has_more(); it.advance()) {
labels_.push_back(Label(*it.cur()));
- base::CheckedNumeric<uint32_t> count = it.repeat();
- labels_.back().count_ = count.ValueOrDie();
+ labels_.back().count_ =
+ base::checked_cast<decltype(labels_.back().count_)>(it.repeat());
}
}

Powered by Google App Engine
This is Rietveld 408576698