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

Unified Diff: components/safe_browsing_db/v4_rice.cc

Issue 2190233002: Rice decode removals and additions and use them to update the store. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@01_v4_rice
Patch Set: Tiny: Remove a comment. Club non-static functions together in .h Created 4 years, 4 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 | components/safe_browsing_db/v4_store.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/safe_browsing_db/v4_rice.cc
diff --git a/components/safe_browsing_db/v4_rice.cc b/components/safe_browsing_db/v4_rice.cc
index b053715083be4305b43e763eb4eb7c8b8ffcc7fa..3016fac87941e381e549b2535eb02e4125423c67 100644
--- a/components/safe_browsing_db/v4_rice.cc
+++ b/components/safe_browsing_db/v4_rice.cc
@@ -106,10 +106,14 @@ V4DecodeResult V4RiceDecoder::DecodeBytes(const int32 first_value,
if (result != DECODE_SUCCESS) {
return result;
}
-
out->reserve((num_entries + 1) * 4);
+
+ // Cast to unsigned since we don't look at the sign bit as a sign bit.
+ // first_value should have been an unsigned to begin with but proto don't
+ // allow that.
+ uint32_t first_value_unsigned = static_cast<uint32_t>(first_value);
+ base::CheckedNumeric<uint32_t> last_value(first_value_unsigned);
char bytes[4];
- base::CheckedNumeric<uint32_t> last_value(first_value);
GetBytesFromUInt32(last_value.ValueOrDie(), bytes);
out->append(bytes, 4);
« no previous file with comments | « no previous file | components/safe_browsing_db/v4_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698